Beefy Boxes and Bandwidth Generously Provided by pair Networks
Your skill will accomplish
what the force of many cannot
 
PerlMonks  

Re^5: Compare two regex patterns

by Anonymous Monk
on Mar 23, 2008 at 00:54 UTC ( [id://675704]=note: print w/replies, xml ) Need Help??


in reply to Re^4: Compare two regex patterns
in thread Compare two regex patterns

Here's how you would do this. Forget minimization, you don't need it. Take NFAs (or DFAs, it doesn't matter) representing all the regexes you want to compare. Mark the final state(s) of each NFA or DFA with something that identifies that particular regex. Then combine them all into a single NFA using alternation. Finally, convert that NFA into a DFA, but when you do, make sure that each final state of the DFA has markers indicating what regex(ex) it was final for.

Now survey all your final states. If all final states have markers for all the regexes, the regexes are equal. You can also use this to determine if one is a subset of another (all final states have markers for regex1, but only some have markers for regex2), if they overlap (at least one final state had markers for both regexes), or if they are completely disjoint (no final state had markers for both).

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://675704]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others rifling through the Monastery: (4)
As of 2024-04-19 23:26 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found