Message from JavaScript discussions

August 2017

— 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!

Message permanent page

— 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???"

— Agreed

— Well that's interesting I guess, I just wonder why you'd need this

— The thing is this also won't work on many regexes since modern regular expressions are not actually regular

Message permanent page

— All regular expressions can be represented as a DFA, although the DFA can be extremely large

— Some regex with overlapping terminals may cause problems but it's just an extra case