日期:2014-05-20 浏览次数:20643 次
public class Test2 { public static void main(String[] args) { String str = " <br/> <br/> <br/> aafsdf\n" + "fas <br/> dfsdf\n" + " <br/>"; String regex = "(?i)\\A(?:\\s*<br\\s*/>)+\\s*|(?:\\s*<br\\s*/>)+\\s*\\Z"; str = str.replaceAll(regex, ""); System.out.println(str); } }