confusables
confusables copied to clipboard
Regex meaningful characters not escaped in confusable_regex
When trying to create a confusable regex from a string like "t[e]st", it will fail to match the string "t[e]st". I believe this is because the characters are not escaped when added to the regex.
Old post, but replying for anyone stumbling across this. One possible approach is to add more padding characters (characters that may be inbetween searched characters), so that instead of having to search for t[e]st, you can just search for 'test'. But brackets are not included as padded/buffer characters. What I did to change / add more was:
bufferMatch, addBuffers = "*_~|`", "*_~|`\[\]\(\)'"
expression = confusable_regex(whatever, include_character_padding=True).replace(bufferMatch, addBuffers)
This takes the regex expression, and replaces any parts with the original set of padding characters, and replaces it with my own, escaped properly. Any can be added.
In your example, it would allow "t[e]st" to be matched with a search for "test"