From 89fee4efe3228d6a9aaa5f92d580e0d5b0146c1d Mon Sep 17 00:00:00 2001 From: Aleksandar Pokopec Date: Mon, 25 Jan 2010 18:21:32 +0000 Subject: Test file for matching with replace. --- test/files/run/ReplacementMatching.scala | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) create mode 100644 test/files/run/ReplacementMatching.scala (limited to 'test/files/run') diff --git a/test/files/run/ReplacementMatching.scala b/test/files/run/ReplacementMatching.scala new file mode 100644 index 0000000000..ab14202871 --- /dev/null +++ b/test/files/run/ReplacementMatching.scala @@ -0,0 +1,27 @@ + + + + + + + + +object Test { + + def main(args: Array[String]) { + val regex = """\$\{(.+?)\}""".r + val replaced = regex.replaceAllMatchDataIn("Replacing: ${main}. And another method: ${foo}.", + (m: util.matching.Regex.Match) => { + val identifier = m.group(1) + identifier + }) + assert(replaced == "Replacing: main. And another method: foo.") + + val regex2 = """\$\{(.+?)\}""".r + val replaced2 = regex2.replaceAllIn("Replacing: ${main}. And then one more: ${bar}.", (s: String) => { + "$1" + }) + assert(replaced2 == "Replacing: main. And then one more: bar.") + } + +} -- cgit v1.2.3