fork(1) download
  1. object Main extends App {
  2. def matchStringLiteral(input: String) = {
  3. val strLit = """("(\\.|[^"])*")""".r
  4. input match {
  5. case strLit(s1, s2) => s"matched literal. Group 1: $s1\nGroup 2: $s2"
  6. case _ => "didn't match anything"
  7. }
  8. }
  9.  
  10. val str = "\"welcome to \\\"GenericWebsiteName.com\\\"\""
  11. println(matchStringLiteral(str))
  12. }
  13.  
Success #stdin #stdout 0.38s 322496KB
stdin
Standard input is empty
stdout
matched literal. Group 1: "welcome to \"GenericWebsiteName.com\""
Group 2: \"