<p class="MsoNormal" style="margin: 0cm 0cm 0pt">&nbsp;<span style="font-family: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">路况信息:受暴雨影响,昨日</span><span lang="EN-US">10</span><span style="font-family: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">时四川</span><span lang="EN-US">S307</span><span style="font-family: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">凉山彝族自治州雷波县境内发生岩石塌方,造成交通中断,车辆可从溪洛渡专用通道绕行,预计</span><st1:chsdate year="2010" month="3" day="20" islunardate="False" isrocdate="False" w:st="on"><span lang="EN-US">3</span><span style="font-family: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">月</span><span lang="EN-US">20</span><span style="font-family: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">日</span></st1:chsdate><span style="font-family: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">恢复通行;</span><span lang="EN-US">G320</span><span style="font-family: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">江西上饶市境内路段发生山体坍塌,造成交通中断,当地公路管理部门正在积极抢通,预计</span><st1:chsdate year="2010" month="3" day="18" islunardate="False" isrocdate="False" w:st="on"><span lang="EN-US">3</span><span style="font-family: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">月</span><span lang="EN-US">18</span><span style="font-family: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">日</span><span lang="EN-US">10</span><span style="font-family: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">时</span></st1:chsdate><span style="font-family: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">恢复通行。</span></p>以上是源码我想得到这个信息
 路况信息:受暴雨影响,昨日10时四川S307凉山彝族自治州雷波县境内发生岩石塌方,造成交通中断,车辆可从溪洛渡专用通道绕行,预计3月20日恢复通行;G320江西上饶市境内路段发生山体坍塌,造成交通中断,当地公路管理部门正在积极抢通,预计3月18日10时恢复通行。能写吗? 应该怎么写?

解决方案 »

  1.   

    你是想抓取别人网页上的东西?还是过滤HTML标记
    需求说清楚点
      

  2.   

    找个编辑器。高亮 'Times New Roman'"> 
    高亮  lang="EN-US">后面的部分截取下。
      

  3.   

    public static String getTxtWithoutHTMLElement (String element) 
      {  // String reg="< [^< |^>]+>";  // return element.replaceAll(reg,"");  if(null==element||"".equals(element.trim()))  {  return element;  }  Pattern pattern=Pattern.compile("< [^< |^>]*>");  Matcher matcher=pattern.matcher(element);  StringBuffer txt=new StringBuffer();  while(matcher.find())  {  String group=matcher.group();  if(group.matches("< [\\s]*>"))  {  matcher.appendReplacement(txt,group);  }  else  {  matcher.appendReplacement(txt,"");  }  }  matcher.appendTail(txt);  repaceEntities(txt,"&","&");  repaceEntities(txt,"< ","< ");  repaceEntities(txt,">",">");  repaceEntities(txt,""","\"");  repaceEntities(txt," ","");  return txt.toString();  }
      

  4.   


    string output = Regex.Replace(input, "(<[^<>]+>|&nbsp;)","");
      

  5.   

    string strs = "<p class=\"MsoNormal\" style=\"margin: 0cm 0cm 0pt\">&nbsp;<span style=\"font-family: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'\">路况信息:受暴雨影响,昨日</span><span lang=\"EN-US\">10</span><span style=\"font-family: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'\">时四川</span><span lang=\"EN-US\">S307</span><span style=\"font-family: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'\">凉山彝族自治州雷波县境内发生岩石塌方,造成交通中断,车辆可从溪洛渡专用通道绕行,预计</span><st1:chsdate year=\"2010\" month=\"3\" day=\"20\" islunardate=\"False\" isrocdate=\"False\" w:st=\"on\"><span lang=\"EN-US\">3</span><span style=\"font-family: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'\">月</span><span lang=\"EN-US\">20</span><span style=\"font-family: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'\">日</span></st1:chsdate><span style=\"font-family: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'\">恢复通行;</span><span lang=\"EN-US\">G320</span><span style=\"font-family: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'\">江西上饶市境内路段发生山体坍塌,造成交通中断,当地公路管理部门正在积极抢通,预计</span><st1:chsdate year=\"2010\" month=\"3\" day=\"18\" islunardate=\"False\" isrocdate=\"False\" w:st=\"on\"><span lang=\"EN-US\">3</span><span style=\"font-family: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'\">月</span><span lang=\"EN-US\">18</span><span style=\"font-family: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'\">日</span><span lang=\"EN-US\">10</span><span style=\"font-family: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'\">时</span></st1:chsdate><span style=\"font-family: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'\">恢复通行。</span></p>";
                string str = System.Text.RegularExpressions.Regex.Replace(strs, "<[^>]+>", "");
                str = System.Text.RegularExpressions.Regex.Replace(str, "&[^;]+;", "");
      

  6.   


    string str = Regex.Replace(test, @"<.*?>|&nbsp;", string.Empty);
      

  7.   

    string output = Regex.Replace(input, "(<[^<>]+>|&nbsp;)","");
      

  8.   


    string output = Regex.Replace(input,@"(?i)(<[^>]+>|&nbsp;)","");