Message from JavaScript discussions

August 2017

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


Message permanent page

— 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