【发布时间】:2014-03-12 02:33:38
【问题描述】:
我正在尝试使用 .NET 正则表达式匹配一些 html 列表标签 <ol>...</ol> 和 <ul>...</ul>。我可以使用
<(ol|ul)( )?>.*</( )?\1>
但前提是没有另一个相同的列表。
例如,这将获得两个命中:
<ol>this is the first list</ol>...<ul>this is the second list</ul>;
但这只会得到一击:
<ol>this is the first list</ol>...<ul>this is the second list</ul>...<ol>this is the third list</ol>
我觉得我需要替换我表情中间的.*,但我无法弄清楚。任何帮助将不胜感激。
编辑:对不起,我想应该提到(@alliteralmind)我专门寻找<ol>和<ul>标签(及其结束标签),这两种类型肯定都包含<li>...</li>元素。
【问题讨论】:
-
不要使用正则表达式解析html