我在C#中遇到了正则表达式的问题。我想分析一个简单的网页的HTML代码。它看起来像这样:C#使用正则表达式分析html代码
<td class="ivu_table_c_dep"> 12:05 </td>
<td class="ivu_table_c_line"> Bus 398 </td>
<td>
<img src="/IstAbfahrtzeiten/img/css/link.gif" alt="" />
<a class="catlink" href="http://mobil.bvg.de/Fahrinfo/bin/stboard.bin/dox?boardType=dep&input=S Mahlsdorf!&time=12:05&date=15.02.2012&&" title="interner Link: Information zu dieser Haltestelle">S Mahlsdorf</a>
我想知道的是“12:05”,“巴士398”和“S Mahlsdorf”。随着第2个部分,我得到它与下面的代码工作:
Regex HTMLTag = new Regex("ivu_table_c_dep\">([^<>]*)</td>([^<>]*)<td class=\"ivu_table_c_line\">([^<>]*)</td>");
但我不明白的3部分。我尝试添加 “([^(\”>)] )([^ <>])”但它doesnt't工作
强制性:http://stackoverflow.com/questions/677038/how-to-use-regular-expressions-to -parse-html-in-java – Oded 2012-02-15 10:59:48
更强制性的:http://stackoverflow.com/questions/1732348/regex-match-open-tags-except-xhtml-self-contained-tags – 2012-02-15 11:24:35