AhoCorasick icon indicating copy to clipboard operation
AhoCorasick copied to clipboard

Wildcard matching

Open tank104 opened this issue 3 years ago • 2 comments

Do you think it would be easy to add wildcard matching to this? Any tips how it might be achieved?

Thinking * for any number of characters, and ? For a single character.

tank104 avatar Apr 01 '21 09:04 tank104

Unfortunately, it's not easy to extend the algorithm to wildcards. Perhaps you could search for all the non-wildcard substrings of your patterns and then perform additional checks to see if the matched substrings are in the correct positions. For example, if you have "ab*cd*ef", then search for "ab", "cd", "ef" and if there's a match then check if the matched indexes are in the correct order, meaning you'd have a match for the whole wildcard pattern.

mganss avatar Apr 01 '21 10:04 mganss

Thanks thats a good idea, we can try exploring that.

tank104 avatar Apr 08 '21 03:04 tank104