Message from JavaScript discussions

August 2017

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

Message permanent page

— 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

Message permanent page

— Ah.

— Thanks

— This is, again, for /hello/ except showing the code points:


and here's what <w{5}> looks like:

Message permanent page

— Not yet but I might

— For now I just made a simple DFA which can function just like a regex

— Parsing the regex to the DFA is another story... haha