I have the following text :
"This is a first test just before a second"
I want to match test, if preceeded by "first" and followed by "just". I also want to allow for up to one misspelling on test.
I could do something like:
import regex
text = "This is a first test just before a second"
text2 = "This is a first ctest just before a second"
pattern = r'(?:first)(test){e<=1}(?:just)'
match = regex.search(pattern, text, regex.IGNORECASE)
However, with the fuzziness allowed, I could potentially return "ctest" with text2.
Using the enhanced match function of regex, something like :
pattern = r'(?e)(test){e<=1}'
works but I am not able to mix it up with the context words I want to include in the pattern (meaning that
r'(?:first)(?e)(test){e<=1}(?:just)'
or r'(?e)((?:first)(test){e<=1}(?:just))'
do not work and still returns the fuzzy match