Skip to content

Instantly share code, notes, and snippets.

@Derekokich
Created August 19, 2014 17:53
Show Gist options
  • Save Derekokich/7cff3dd43c1424a68b62 to your computer and use it in GitHub Desktop.
Save Derekokich/7cff3dd43c1424a68b62 to your computer and use it in GitHub Desktop.
regexblog11
object Regex {
def fullMatch(input: String, pattern: String) = {
val parsed = RegexParser(pattern).getOrElse(
throw new RuntimeException("Failed to parse regex")
)
val nfa = NFA.regexToNFA(parsed)
NFAEvaluator.evaluate(nfa, input)
}
def matchAnywhere(input: String, pattern: String) =
fullMatch(input, ".*" + pattern + ".*")
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment