Create regular expression matching

The termination condition is important! It's like an automata machine.