Matcher's matches() method returns false, find() and groupCount() return results

后端 未结 1 1395
孤独总比滥情好
孤独总比滥情好 2020-12-11 21:39

I have the following code:

private static final String ET_AL = \"(\\\\p{Punct}|\\\\b|^|\\\\s)et\\\\.? al\\\\.?(\\\\b|$|\\\\s)\";
private static final Pattern         


        
相关标签:
1条回答
  • 2020-12-11 22:25

    but the call to m.matches() returns false.

    It is because Matcher#matches() requires you to match complete input with your regex.

    From Javadoc:

    public boolean matches()

    Attempts to match the entire region against the pattern. If the match succeeds then more information can be obtained via the start, end, and group methods.

    0 讨论(0)
提交回复
热议问题