# Message from JavaScript discussions

August 2017

— Https://gist.github.com/Floofies/2dedaaf1af1dfbe1402453fbc18a39a2

Hmmm! Might be making a `RegExp`

diff algorithm that diffs them based on what they can understand rather than direct string comparison... this is a little quick deterministic finite automata implementation I wrote for fun, but will likely have some use in the diff algorithm

— The bottom is a DFA that can understand `HELLO`

— `RegExp`

: `/hello/`

is equivalent to DFA:

-->(s1)-H->(s2)-E->(s3)-L->(s4)-L->(s5)-O->((s6))

— So it then becomes a graph diff problem! :D

— Not sure what you mean?

— You can convert a regular expression to a deterministic finite automata

— Then traverse that automata tree and derive strings... you can traverse infinite amounts at the same time and find out if they all derive the same strings

— Nice.

— They are 1:1 mapping as a DFA and regex can describe each other 100%

— So if you have `<w{5}>`

how can you tell it derives the same string as `/hello/`

without passing in any data or otherwise running the regular expression builtins? You do simple comparison operators on the transition ranges between the nodes, very simple!

— All ranges for the first one would be `{0, 65535}`

whereas for the second one it would vary... `{72, 72}`

and then `{69, 69}`

etc... since the ranges of the second expression fit into the ranges of the first you can say "Yes, these two expressions can derive the same string". If you want a strict result that says "these two expressions derive the same EXACT strings, no more and no less", then you can do a direct strict equality comparison instead