在PHP中我可以检查一个单词是否在这样的字符串中
$muster = "/\b($word)\b/i";
if(preg_match($muster, $text)) {
return true;
}
例:
$word = "test";
$text = "This is a :::test!!!";
返回true
我尝试将其转换为Java:
if (Pattern.matches("(?i)\\b(" + word + ")\\b", text)) {
return true;
}
同样的例子:
String word = "test";
String text = "This is a :::test!!!";
将返回false
我在这里错过了什么? :(