模式匹配不起作用,但是为什么呢?
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("(?<! )&", " &")
}
}
给定的字符串应该匹配,这不是为什么吗?