【发布时间】:2012-02-18 23:23:21
【问题描述】:
我正在尝试匹配所有没有属性“term”或“range”的 HTML 标记
这里是示例 HTML 格式
<span class="inline prewrap strong">DATE:</span> 12/01/10
<span class="inline prewrap strong">MR:</span> 1234567
<span class="inline prewrap strong">DOB:</span> 12/01/65
<span class="inline prewrap strong">HISTORY OF PRESENT ILLNESS:</span> Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book. It has survived not only five centuries, but also the leap into electronic typesetting, remaining essentially unchanged. It was popularised in the 1960s with the release of Letraset sheets containing Lorem Ipsum passages, and more recently with desktop publishing software like Aldus PageMaker including versions of Lorem Ipsum
<span class="inline prewrap strong">MEDICATIONS:</span> <span term="Advil" range="true">Advil </span>and Ibuprofen.
我的正则表达式是:<(.*?)((?!\bterm\b).)>
不幸的是,这匹配了所有标签...如果内部文本不匹配,那就太好了,因为我需要过滤掉除具有特定属性的标签之外的所有标签。
【问题讨论】:
-
您能否详细说明您正在尝试做什么?您是要过滤掉所有具有“术语”或“范围”属性的标签,还是所有没有“术语”或“范围”属性的标签?
-
我正在尝试过滤掉所有没有“term”和“range”属性的标签。基本上在我做了一个 replace() 之后,只有具有这些属性的标签应该仍然存在。
标签: regex pattern-matching string-matching