String strs="<SPAN id=dfe540c8-1161-45cd-83ae-120eee728849 contentEditable=false Type=2>[010001][2] </SPAN>"  
             +"<SPAN id=dfe540c8-1161-45cd-83ae-120eee728841 contentEditable=false Type=2>[100001][1] </SPAN>"
             +"<SPAN id=cds540c3-2321-45cd-83ae-120eee728842 style=\"clor:red\">出口温度[320001] </SPAN>"
             +"<SPAN id=df6540c8-5465-45cd-83ae-120eee728843 style=\"clor:red\">出口压力[540002] </SPAN>"
             +"<SPAN id=df3340c8-5465-45cd-83ae-120eee712844><b>√ </b></SPAN>"
             +"<SPAN id=df3340c8-5465-45cd-83ae-120eee712845><b>√ </b></SPAN>"
             +"<SPAN id=df3340c8-5465-45cd-83ae-120eee712846>出口压力[540002] </SPAN>";上次问题还未解决,没有解决根本问题。望解答。
怎样用正则表达示得到<span>标签里面类似[010001][2],XXXXXX[320001]的内容。(XXXXX可以代表任意文字)
用集合存放起来.

解决方案 »

  1.   

    过滤掉<b>√ </b>的标准是什么?
      

  2.   


    将SPAN标签里面内容(如<b>√ </b>) 带有<>全部过滤掉
      

  3.   

    <SPAN id=df3340c8-5465-45cd-83ae-120eee712845>m>n</SPAN>可以不?
    <SPAN id=df3340c8-5465-45cd-83ae-120eee712845>m<n</SPAN>可以不?
      

  4.   

    LZ意思是过滤<span>标签和<b>标签所以内容??
      

  5.   

    <span><span>asas</span></span>有没有可能呢?
      

  6.   


    <SPAN\\s+[^<>]*>([^<>]+)</SPAN>试情况而定
      

  7.   

    应该没问题了ArrayList<String> al = new ArrayList<String>();
    Pattern p = Pattern.compile("(<SPAN.+?>)([.[^SPAN]]+?\\d+?.+?)(?:</SPAN>)");
    String str = "<SPAN id=dfe540c8-1161-45cd-83ae-120eee728849 contentEditable=false Type=2>[010001][2] </SPAN>"  
      +"<SPAN id=dfe540c8-1161-45cd-83ae-120eee728841 contentEditable=false Type=2>[100001][1] </SPAN>"
      +"<SPAN id=cds540c3-2321-45cd-83ae-120eee728842 style=\"clor:red\">出口温度[320001] </SPAN>"
      +"<SPAN id=df6540c8-5465-45cd-83ae-120eee728843 style=\"clor:red\">出口压力[540002] </SPAN>"
      +"<SPAN id=df3340c8-5465-45cd-83ae-120eee712844><b>√ </b></SPAN>"
      +"<SPAN id=df3340c8-5465-45cd-83ae-120eee712845><b>√ </b></SPAN>"
      +"<SPAN id=df3340c8-5465-45cd-83ae-120eee712846>出口压力[540002] </SPAN>";
    Matcher m = p.matcher(str);
    while(m.find()) {
    al.add(m.group(2));
    System.out.println(m.group(2));
    }[010001][2] 
    [100001][1] 
    出口温度[320001] 
    出口压力[540002] 
    出口压力[540002]