diff options
author | Aleksandar Pokopec <aleksandar.prokopec@epfl.ch> | 2010-02-09 15:31:11 +0000 |
---|---|---|
committer | Aleksandar Pokopec <aleksandar.prokopec@epfl.ch> | 2010-02-09 15:31:11 +0000 |
commit | 71e03e4aca90be26290ab222d2d5131c5b2d42db (patch) | |
tree | fd1da647346c01e7b0b447637d1502c74844a22b /test/files | |
parent | 1b99b4b148b04d0eafd6bd3fb55309c29f60eb2d (diff) | |
download | scala-71e03e4aca90be26290ab222d2d5131c5b2d42db.tar.gz scala-71e03e4aca90be26290ab222d2d5131c5b2d42db.tar.bz2 scala-71e03e4aca90be26290ab222d2d5131c5b2d42db.zip |
`replaceSomeIn` method added.
Diffstat (limited to 'test/files')
-rw-r--r-- | test/files/run/ReplacementMatching.scala | 11 |
1 files changed, 6 insertions, 5 deletions
diff --git a/test/files/run/ReplacementMatching.scala b/test/files/run/ReplacementMatching.scala index 30c525b63c..05040d98a3 100644 --- a/test/files/run/ReplacementMatching.scala +++ b/test/files/run/ReplacementMatching.scala @@ -15,18 +15,19 @@ object Test { def replacementMatching { val regex = """\$\{(.+?)\}""".r - val replaced = regex.replaceAllMatchesIn("Replacing: ${main}. And another method: ${foo}.", + val replaced = regex.replaceAllIn("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" + val regex3 = """\$\{(.+?)\}""".r + val replaced3 = regex3.replaceSomeIn("Replacing: ${main}. And another: ${foo}.", (m: util.matching.Regex.Match) => { + val id = m.group(1) + if (id.startsWith("m")) Some(id) else None }) - assert(replaced2 == "Replacing: main. And then one more: bar.") + assert(replaced3 == "Replacing: main. And another: ${foo}.") } def groupsMatching { |