From 817317824a1c62eabd9e09b7d2e98494292d8695 Mon Sep 17 00:00:00 2001 From: michelou Date: Wed, 30 Jan 2008 16:11:00 +0000 Subject: forget to ci test file (regexp pattern) --- test/files/run/bug0325.scala | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) (limited to 'test/files') diff --git a/test/files/run/bug0325.scala b/test/files/run/bug0325.scala index dc05a8d777..236f1b101f 100644 --- a/test/files/run/bug0325.scala +++ b/test/files/run/bug0325.scala @@ -1,8 +1,15 @@ case class RS(self: String) { - def split(separator: Char): Array[String] = self.split("\\Q"+separator+"\\E") + + // NB. "\\Q" + '\\' + "\\E" works on Java 1.5 and newer, but not on Java 1.4 + private def escape(ch: Char): String = ch match { + case '\\' => "\\\\" + case _ => "\\Q"+ch+"\\E" + } + + def split(separator: Char): Array[String] = self.split(escape(separator)) def split(separators: Array[Char]): Array[String] = { - val re = separators.foldLeft("[")(_+"\\Q"+_+"\\E") + "]" + val re = separators.foldLeft("[")(_+escape(_)) + "]" self.split(re) } } -- cgit v1.2.3