Is there any solution that can compare two regular expression for Subsumption, Partially overlapping, disjoint i.e. i want to know how to compare two regular expression. Secondly can i combine two regular expression if regex 1 is subsumpted by regex 2.
Is there any solution that can compare two regular expression for Subsumption, Partially overlapping,
Share
Say you have two expressions A and B and want to see if A matches a subset of what B does.
You need to compute the minimized DFA of B and then combine the two expressions to make a union of A and B and then compute the minimized DFA of that new expression. If those two DFAs are equal then A matches a subset of B.
In essence, you can’t properly check this without going through the process of constructing a minimized automata. It will however, give a verifiable true answer to the question.
Combining the two expressions can be done by making a new expression like
(A)|(B), perhaps substituting the paranthesis for non-capturing varieties if your engine supports that.If you decide to go the whole way to do the algorithms, I’ve written a series of articles on the process:
http://binarysculpting.com/2012/02/11/regular-expressions-how-do-they-really-work-automata-theory-for-programmers-part-1/
http://binarysculpting.com/2012/02/15/converting-dfa-to-nfa-by-subset-construction-regular-expressions-part-2/
http://binarysculpting.com/2012/03/21/dfa-state-minimization/
To compare two automatas you could just check that the states and transitions are the same. They should be exactly equal.