I’m not sure if this is possible, so sorry if this sounds a little vague. In JavaScript I’m matching strings with those found in text layers in Photoshop (text contents). This is all well and good with short strings.
However, with longer strings they might not match due to missing off a full stop or having leading white space or including a newline or a missing comma (due to delimtation).
I suppose a better way would be to match exactly the first, say 16 or 32 characters and leave it at that. But I was wondering if you could match the string on a percentile basis; and accept the ones over 90% (wide error margin, I know but the strings aren’t likely to be similar) How would I go about this? Is there a thing as fuzzy regex?
Thank you.
You can remove all white space, dots, and other irrelevant stuff with a substitution and try to match the remaining text with your regex. This is somehow fuzzy 🙂 since you lose some tokens but would still give you correct results. For example, instead of searching for ‘XXX YYY’ search for ‘XXXYYY’.