日期:2014-05-17 浏览次数:20861 次
Pattern pattern = Pattern.compile("<.+?>");
Matcher matcher = pattern.matcher("<pre class='prettyprint lang-java'>aaaa</pre>");
String str = matcher.replaceAll("");
System.out.println(str);
String regex = "<pre class=\"prettyprint lang-.*?\">(.*?)</pre>";
String input = "<pre class=\"prettyprint lang-java\">Configuration cfg = new Configuration().configure();cfg.buildSessionFactory();</pre>";
Pattern p = Pattern.compile(regex);
Matcher m = p.matcher(input);
while (m.find()) {
System.out.println(m.group(1));
}