0
我正在学习正则表达式和更具体的单词边界。我有一段代码,我觉得应该返回至少一个匹配,但它不是。试图理解单词边界
什么是错的代码我用
public static void main(String[] args)
{
boolean matches;
String [] various = {"Men of honour", "X Men", "Children of men", "Company men are great"};
for(int i = 0; i < various.length; i++)
{
matches = Pattern.matches("\\bMen", various[i]);
System.out.println("Does the string match the pattern? " + matches);
}
}
放出来是遵循
Does the string match the pattern? false
Does the string match the pattern? false
Does the string match the pattern? false
Does the string match the pattern? false