我发现这个真的比较难诶有这方面的书买不?我想认真学学!
<div class="Weather_TP">雨夹雪 3℃~1℃</div>
怎么提取所有这个<div class="Weather_TP"> 和这个</div>之间的信息呢?
<div class="Weather_TP">雨夹雪 3℃~1℃</div>
怎么提取所有这个<div class="Weather_TP"> 和这个</div>之间的信息呢?
Pattern p = Pattern.compile("<div\\s+class\\s*=\\s*\"Weather_TP\"\\s*>(.*?)</div>");
Matcher m = p.matcher(str);
if (m.find()) {
System.out.println(m.group(1));
}
<div class="Weather_TP">雨夹雪转小雪 2℃~0℃</div>得出的是这个答案 去掉这些 <div class="Weather_TP"> </div>怎么搞?
Jeffrey E.F.Friedl, Mastering Regular Expressions
中文版:《精通正则表达式》,已由电子工业出版社于2007年7月出版。中文版挺贵的,定价75块钱。对于Java中的正则表达式,可以参看,Java Tutorial有关正则表达式的部分:
http://java.sun.com/docs/books/tutorial/essential/regex/index.html