I am looking for a solution to match a single line with a set of wildcards. for instance
>>> match("ab", ["a*", "b*", "*", "c", "*b"]) ["a*", "*", "*b"]
The order of output does not matter.
I will have about 10 ^ 4 wildcards to match, and I will make about ~ 10 ^ 9 matches. This means that I will probably have to rewrite my code like this:
>>> matcher = prepare(["a*", "b*", "*", "c", "*b"] >>> for line in lines: yield matcher.match("ab") ["a*", "*", "*b"]
I started writing a trie implementation in Python that handles wildcards, and I just need to get these corner cases correctly. Despite this, I am curious to hear; How would you solve this? Are there any Python libraries out there that make me solve this faster?
Some ideas so far:
- Named (Python, re) regular expressions will not help me, because they will return only one match.
- pyparsing seems like an amazing library, but is rarely documented and, as I see it, does not support matching multiple patterns.
source share