日期:2014-05-18 浏览次数:20740 次
StringBuffer sb = new StringBuffer(""); sb.append("test \r\n"); sb.append("<% \r\n"); sb.append("a=\"asfdsaf%\" \r\n"); sb.append("response.write a \r\n"); sb.append("%> \r\n"); sb.append("tttt \r\n"); sb.append("<% \r\n"); sb.append("b=\"2323423sdfasdf2\" \r\n"); sb.append("response.write b \r\n"); sb.append("%>\r\n"); Pattern p = Pattern.compile("<%(.|\r\n)*?(?=%>)%>"); Matcher m = p.matcher(sb.toString()); while(m.find()){ System.out.println("1: "+m.group(0)); }
------解决方案--------------------
大菜鸟 果然不同凡响 呵呵
正则很厉害啊
佩服