Fixed Regular Match issues, all test cases pass

This modification does not fit for large test cases, which will cause
time out exception. But for small case, it works well. And the basic
idea based on FSM state machine and using recursive for mock up FSM.