Created
August 19, 2014 17:53
-
-
Save Derekokich/7cff3dd43c1424a68b62 to your computer and use it in GitHub Desktop.
regexblog11
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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