I\'m just wondering if it\'s possible to use one regular expression to match another, that is some sort of:
[\'a-z\'].match([\'b-x\'])
True
[\'m-n\'].match(
I think — in theory — to tell whether regexp A
matches a subset of what regexp B
matches, an algorithm could:
B
and also of the "union" A|B
.However, it would likely be a major project to do this in practice. There are explanations such as Constructing a minimum-state DFA from a Regular Expression but they only tend to consider mathematically pure regexps. You would also have to handle the extensions that Python adds for convenience. Moreover, if any of the extensions cause the language to be non-regular (I am not sure if this is the case) you might not be able to handle those ones.
But what are you trying to do? Perhaps there's an easier approach...?