Why is Pattern Matching not working in Scala?

Viewed 52

the Pattern Matching is not working but why?

def replaceEmployerNameContainingAmpersand(emplName: String): String = {
   val r = "(?<! )&(?! )".r
   val r2 = "&(?! )".r
   val r3 = "(?<! )&".r

   emplName match {

     case r() => emplName.replaceAll("(?<! )&(?! )", " & ")

     case r2() => emplName.replaceAll("&(?! )", "& ")

     case r3() => emplName.replaceAll("(?<! )&", " &")


   }
 }

The given String should match it is not why?

0 Answers
Related