日期:2014-05-20  浏览次数:20826 次

正则表达式-后向引用?
Java code

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
-----------^---------------


------解决方案--------------------
探讨
小括号和\\k造成的吧..
不太明白正则的意思,貌似?用法有误...