首页 新闻 会员 周边

关于java 的 正则处理

0
悬赏园豆:50 [已关闭问题]

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这样写有问题

问题补充: 大家看看 http://www.cnblogs.com/ruonanxiao/ 上面的成果
ruonanxiao的主页 ruonanxiao | 初学一级 | 园豆:6
提问于:2009-08-28 11:28
< >
分享
清除回答草稿
   您需要登录以后才能回答,未注册用户请先注册