summaryrefslogtreecommitdiff
path: root/test/files/run
diff options
context:
space:
mode:
authorAleksandar Pokopec <aleksandar.prokopec@epfl.ch>2010-01-25 18:21:32 +0000
committerAleksandar Pokopec <aleksandar.prokopec@epfl.ch>2010-01-25 18:21:32 +0000
commit89fee4efe3228d6a9aaa5f92d580e0d5b0146c1d (patch)
tree3320168593c6f2176aa5964399a2fda16f7a7e2e /test/files/run
parent0516cd02f1ad19e9dfb1e4a4fbe198932bf8b2e2 (diff)
downloadscala-89fee4efe3228d6a9aaa5f92d580e0d5b0146c1d.tar.gz
scala-89fee4efe3228d6a9aaa5f92d580e0d5b0146c1d.tar.bz2
scala-89fee4efe3228d6a9aaa5f92d580e0d5b0146c1d.zip
Test file for matching with replace.
Diffstat (limited to 'test/files/run')
-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.")
+ }
+
+}