Python's new regex module supports fuzzy string matching. Sing out loud (now).
In documents:
The flag ENHANCEMATCHattempts a fuzzy match to improve the match of the next match it finds.The flag BESTMATCHsearches for fuzzy matches for the best match instead of the next match
The flag ENHANCEMATCHattempts a fuzzy match to improve the match of the next match it finds.
ENHANCEMATCH
The flag BESTMATCHsearches for fuzzy matches for the best match instead of the next match
BESTMATCH
The flag is ENHANCEMATCHset using (?e), as in
(?e)
regex.search("(?e)(dog){e<=1}", "cat and dog")[1] returns "dog"
regex.search("(?e)(dog){e<=1}", "cat and dog")[1]
but the flag is not actually set BESTMATCH. How it's done?
BESTMATCH ( ). Poke-n-hope , BESTMATCH (?b).
(?b)
>>> import regex >>> regex.search(r"(?e)(?:hello){e<=4}", "What did you say, oh - hello")[0] 'hat d' >>> regex.search(r"(?b)(?:hello){e<=4}", "What did you say, oh - hello")[0] 'hello'