<table cellspacing="0" cellpadding="0"><tr><td class="t_f" id="postmessage_29">
第一行:一些内容<br />
第二行:一些内容<br />
</td></tr></table>求一个正则表达式,将里面文字弄出来,或者能够将第一行:一些内容<br />
第二行:一些内容<br />这段东西弄出来,然后自己在提取里面的文字。
第一行:一些内容<br />
第二行:一些内容<br />
</td></tr></table>求一个正则表达式,将里面文字弄出来,或者能够将第一行:一些内容<br />
第二行:一些内容<br />这段东西弄出来,然后自己在提取里面的文字。
String testStr = "<table cellspacing=\"0\" cellpadding=\"0\"><tr><td class=\"t_f\" id=\"postmessage_29\">\n 第一行:一些内容<br />\n 第二行:一些内容<br />\n </td></tr></table>";
String reg = "(.*<br />)";
Pattern p = Pattern.compile(reg);
Matcher matcher = p.matcher(testStr);
if (matcher.find()) {
int gc = matcher.groupCount();
for (int i = 0; i <= gc; i++) {
System.out.println("group " + i + " :" + matcher.group(i));
}
}
public static void main(String[] args) {
String testStr = "<table cellspacing=\"0\" cellpadding=\"0\"><tr><td class=\"t_f\" id=\"postmessage_29\">\n 第一行:一些内容<br />\n 第二行:一些内容<br />\n </td></tr></table>";
String reg = "(.*<br />)";
Pattern p = Pattern.compile(reg);
Matcher matcher = p.matcher(testStr);
while (matcher.find()) {
System.out.println(matcher.group(1));//获取被匹配的部分
}
}
用
String reg = "[>\r\n\\s]*(.*)<br />";