Skip to content Skip to sidebar Skip to footer

Creating Fuzzy Matching Exceptions With Python's New Regex Module

I'm testing the new python regex module, which allows for fuzzy string matching, and have been impressed with its capabilities so far. However, I've been having trouble making cert

Solution 1:

Try a negative lookahead instead:

(?![NEW]|SS)(ST LOUIS){e<=1}

(ST LOUIS){e<=1} matches a string meeting the fuzzy conditions placed on it. You want to prevent it from starting with [NSEW]. A negative lookahead does that for you (?![NSEW]). But your desired string starts with an S already, you only want to exclude the strings starting with an S added to the beginning of your string. Such a string would start with SS, and that's why it's added to the negative lookahead.

Note that if you allow errors > 1, this probably wouldn't work as desired.

Post a Comment for "Creating Fuzzy Matching Exceptions With Python's New Regex Module"