我正在尝试使用 scala 替换字符串中单词的完全匹配
"\\bhello\\b".r.replaceAllIn("hello I am helloclass with hello.method","xxx")
output >> xxx I am helloclass with xxx.method
我想要的是在 helloclass 和 hello.method 中替换单词是否完全是 hello 而不是 hello
xxx I am helloclass with hello.method
如果输入字符串是
"hello.method in helloclass says hello"
"hello.method says hello from helloclass"
"hello.method in helloclass says Hello and hello"
输出应该是
"hello.method in helloclass says xxx"
"hello.method says xxx from helloclass"
"hello.method in helloclass says Hello and xxx"
我怎样才能做到这一点?