changing implementation to use thompsons nfa instead of memoized backtracking