summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--test/files/run/ReplacementMatching.scala27
1 files changed, 27 insertions, 0 deletions
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.")
+ }
+
+}