我发现这个真的比较难诶有这方面的书买不?我想认真学学!
<div class="Weather_TP">雨夹雪 3℃~1℃</div>
怎么提取所有这个<div class="Weather_TP"> 和这个</div>之间的信息呢?

解决方案 »

  1.   

    已经有人问过这个问题了!    String str = "<div   class=\"Weather_TP\"> 雨夹雪   3℃~1℃ </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));
        }
      

  2.   

    java2000_net  版主 有这方面的教材不?碰到这种问题老这样问 也不是个事啊
      

  3.   

    我这里有一个基础的!http://www.java2000.net/viewthread.jsp?tid=22
      

  4.   

    <div class="Weather_TP">阴转多云 3℃~0℃</div>
    <div class="Weather_TP">雨夹雪转小雪 2℃~0℃</div>得出的是这个答案  去掉这些 <div class="Weather_TP"> </div>怎么搞?
      

  5.   

    http://www.unibetter.com/deerchao/zhengzhe-biaodashi-jiaocheng-se.htm按照老紫竹的代码就可以得到你要的结果啊.
      

  6.   

    匹配的串也可以这样写:<div[^>]+>(.*?)</div>
      

  7.   

    有的,有一本权威的正则表达式的书:
    Jeffrey E.F.Friedl, Mastering Regular Expressions
    中文版:《精通正则表达式》,已由电子工业出版社于2007年7月出版。中文版挺贵的,定价75块钱。对于Java中的正则表达式,可以参看,Java Tutorial有关正则表达式的部分:
    http://java.sun.com/docs/books/tutorial/essential/regex/index.html