Get next state index for StateMachine and implement class Regex.