String pipei = "<tr[^>]*>[\\s]*<td[^>]*>[\\s]*(ced){1}[\\s\\S]*?<\\/td>[\\s]*<\\/tr>";
PatternCompiler c = new Perl5Compiler();
try {
org.apache.oro.text.regex.Pattern pattern = c.compile(pipei);
PatternMatcher matcher = new Perl5Matcher();
String html = ReadHtml.GetHtml();
String s1 = "<table><tr><td> ced iuoooiuuio </td></tr> <tr><td>ced tt45654645654 </td></tr> <tr><td>cedtt45654645654 </td></tr></table>";
if(matcher.contains(s1,pattern))
{
MatchResult result = matcher.getMatch();
System.out.println(result.group(0));
System.out.println(result.group(1));
System.out.println(result.groups());
System.out.print(pattern.getPattern());
}
} catch (MalformedPatternException e) {
// TODO 自动生成 catch 块
e.printStackTrace();
}
为什么 第一个能<tr><td> ced iuoooiuuio </td></tr> 匹配到 第二个却是 ced
上面的正则用工具测试都没问题的。是不是我java这样写有问题