Scala currently has a method StringLike.r for compiling strings to regexes.
Now that Scala has string interpolation and macros (since 2.10) I think we can do even better with a r method on StringContext. Here is why:
"\\d+".r"""\d+""".rr"\d+"("foo"+Pattern.escape(bar)).rr"foo$bar"val re = """\d+(.*)\d+""".r; s match { case `re`(x) => x }case r"\d+$x\d+" => xI have a proof of concept implementation available.
Note: This is filed in the Scala issue tracker as SI-7496.