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

正则式,为什么还是贪婪匹配???
String   str   =   " <td> <p> aa </p> </td>   <td> <p> bb </p> </td> ";
Pattern   p   =   Pattern.compile( " <td> (.*?) </td> ");
Matcher   m   =   p.matcher(str);
if(m.matches()){
System.out.println(m.group());
}

都用了(.*?)了还是匹配了整个串

------解决方案--------------------
你获取的方法不对吧
while(m.find()) {
System.out.println(m.group());
}