People often like to meme about RegExp being Turing complete, but all the problems we have looked at so far are single pattern matches.
To do extended computation we need to add memory. So today we are looking at RegExp replace in JS.
This function substitutes a match in a string for a different string, allowing us to store data between repeated run.
You know where else substitution is used to do computation? Arithmetic! The goal today is to write a set of RegExp that solves addition and multiplication problems.
Problems will only use numbers, parenthesis, plus, and times.
All RegExp in the table bellow will be run repeatedly with the global flag.
For your convenience 81*2 RegExp that solve multiplication and addition for 1-9 are included. The remaining logic should not require unrolling or code generated expressions.