in reply to Re^2: Compare two regex patterns
in thread Compare two regex patterns
not for all regexps (that would solve the halting problem :-) ),
To digress a bit on theory: for regular expressions that isn't hard at all.
Once you have a DFA for your regex, you can build the minimal DFA (that can be done in O(n²) or O(n³), not sure...). You can do that for both regexes you compare, and if the DFAs are isomorphic, both regexes are equivalent.
Note that checking if two DFAs are isomorphic isn't hard either, because you know the start state.
But of course Perl's regexps are not regular (in the CS sense), so you can forget everything I said if you're only after a practical solution.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^4: Compare two regex patterns
by vbar (Novice) on Mar 06, 2008 at 17:48 UTC | |
by Anonymous Monk on Mar 23, 2008 at 00:54 UTC | |
|
Re^4: Compare two regex patterns
by Anonymous Monk on Mar 23, 2008 at 00:39 UTC |