Message from JavaScript discussions
August 2017
— For a range, you check if your range for regex 1 is within or equal to the range of regex 2 for that specific node
You can do a "loose" diff and find out if they are capable of deriving SOME of the same strings, too
— If you want to be strict: node1.transition.range[0] === node2.transition.range[0]
etc...
— With g
flag it is also possible to diff
— If you have two regex, say one is 10 characters and the other is 10 million.... but they can derive the exact same strings, but you can't tell that by comparing the source strings or running them...
— The resulting DFA for each one would then be equivalent and as simple as a graph diff
— With global flag, /hello/
looks like this:
-->(s1)-h->(s2)-e->(s3)-l->(s4)-l->(s5)-o->((s6))
^___________________ε___________________/
— Epsilon (an E-move) automatically transitions to a node... with g
flag it basically says "keep going after first match", meaning that E-move is followed!
— So /hello/g
matches to hellohellohellohello
etc...
— Whereas without, it only gets that first one
— Heh, well I am trying to balls-up my graph theory library XD
— I talked to senior engineer at my job and he was like "who needs that and are they on drugs???"