| 发表于:2007-08-01 11:13:394楼 得分:15 |
对正则不是很熟悉。 下面给个能实现你要求的,也许麻烦点. 我写的测试例子: string regex = " <[aa].*?> ";//去掉 <a href= "... "> string regex1 = " </[aa]> ";//去掉 </a> string content = "你好, <b> a </b> <font> 5 </font> <a href=\ "http://www.bontray.cn\ "> 股票知识 </a> ,测试 "; pattern p = pattern.compile(regex); matcher m = p.matcher(content); string strtrim = m.replaceall( " "); pattern p1 = pattern.compile(regex1); matcher m1 = p1.matcher(strtrim); strtrim = m1.replaceall( " "); system.out.println( "strtrim======== "+strtrim); 打印结果: strtrim========你好, <b> a </b> <font> 5 </font> 股票知识,测试 | | |
|