Implement NFA and Regex.