public class Test { public static void main(String[] args) { String str = "go go";
String r5 = "\\b(?<Word>\\w+)\\b\\s+\\k<Word>\\b";
System.out.println(str.matches(r5));
}
}
怎么编译是错误呢?Exception in thread "main" java.util.regex.PatternSyntaxException: Look-behind group does not have an obvious maximum length near index 12
\b(?<Word>\w+)\b\s+\k<Word>\b
-----------^---------------
------------^---------------
\b(? <Word>\w+)\b\s+\k <Word>\b
---------------^---------------
\b(? <Word>\w+)\b\s+\k <Word>\b
----------------^---------------
看不懂什么意思。建议LZ把你要这正则干什么说明白。