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(
In addition to antinome's answer:
Many of the constructs that are not part of the basic regex definition are still regular, and can be converted after parsing the regex (with a real parser, because the language of regex is not regular itself): (x?)
to (x|)
, (x+)
to (xx*)
, character classes like [a-d]
to their corresponding union (a|b|c|d)
etc. So one can use these constructs and still test whether one regex matches a subset of the other regex using the DFA comparison mentioned by antinome.
Some constructs, like back references, are not regular, and cannot be represented by NFA or DFA.
Even the seemingly simple problem of testing whether a regex with back references matches a particular string is NP-complete (http://perl.plover.com/NPC/NPC-3COL.html).