I have such pattern:
(?m).*\\bkey\b\\s+(\\w+)\\s+(\\w+).* and for example, such a text:
key type value When searching with the .find () function, I display all groups:
for (int i = 0; i < matcher.groupCount(); i++) { System.out.println(matcher.group(i)); } but here for some reason it does not display the 'value', the result:
key type value type What can be wrong?
key\b- typo? It is necessaryfor (int i = 0; i <= matcher.groupCount(); i++)- Wiktor Stribiżew