日期:2014-05-20 浏览次数:20922 次
String str = "abc,afda,fdadfae,fdaee,fdafda,efdaf"; Matcher m = Pattern.compile("(?<=^(?:[^,]+,){5})[^,]+(?=\\b|,)").matcher(str); if(m.find()) { System.out.println(m.group(0)); }
Exception in thread "main" java.util.regex.PatternSyntaxException: Look-behind group does not have an obvious maximum length near index 17 (?<=^(?:[^,]+,){5})[^,]+(?=\b|,) ^ at java.util.regex.Pattern.error(Pattern.java:1713) at java.util.regex.Pattern.group0(Pattern.java:2488) at java.util.regex.Pattern.sequence(Pattern.java:1806) at java.util.regex.Pattern.expr(Pattern.java:1752) at java.util.regex.Pattern.compile(Pattern.java:1460) at java.util.regex.Pattern.<init>(Pattern.java:1133) at java.util.regex.Pattern.compile(Pattern.java:823) at com.rmouse.TestMagicCard.main(TestMagicCard.java:37)