1.Java写txt文件,如果换行需要用/r/n
2.java正则表达式,如果需要提取匹配字符串的子串,则给模式串加括号,然后用group(x)来提取
Pattern pat = Pattern.compile(
"(<font color=''>)(.*)(</font></a></td><td align='center' width='14%' nowrap class='postTime'>)(.*)(</td></tr></table></td>)"
);
Matcher mat = pat.matcher(str);
while(mat.find()){
file.write(mat.group(2)+"\t"+mat.group(4)+"\r\n");
System.out.println(mat.group(2)+"\t"+mat.group(4));
}