Skip to content

Instantly share code, notes, and snippets.

@ghidalgo3
Created October 12, 2014 18:45
Show Gist options
  • Save ghidalgo3/97fe0b2bf33b7e30f0ac to your computer and use it in GitHub Desktop.
Save ghidalgo3/97fe0b2bf33b7e30f0ac to your computer and use it in GitHub Desktop.
What should this do?
/** @return string with all occurrences of regex replaced with the paired string returned by supplying the match generated by the regex. Ensures recursive replacements cannot occur. */
def findRegexReplaceMatch(
s: String,
zomRegex: Seq[(Regex, Match => String)]
) : String = {
var t = s
for((regex, matchingFunc) <- zomRegex) {
t = regex.replaceAllIn(t, matchingFunc)
}
t
/*zomRegex.map{
case (regex, matcher) =>
regex.replaceAllIn(s, matcher)
}.mkString*/
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment