我想从html中取段落或div,但是如果它不包含表单。 例如:正则表达式匹配没有子字符串的字符串
<p><form>I don't want this text</form>and not this text</p>
<p>I want to take this text</p>
我有工作变体,没有窗体过滤器。
/(?:<(?:p|div)[^>]*>)(.*)(?:<\/(?:p|div)>)/iu
以及不变形与过滤
/(?:<(?:p|div)[^>]*>)((?:.(?!<form))*)(?:<\/(?:p|div)>)/iu
你能帮助我吗?
究竟是不是工作在哪些情况下没有给出错误的结果(什么是在这些情况下,预期的结果) – Keelan
http://stackoverflow.com/questions/1732 348/regex-match-open-tags-except-xhtml-self-contained-tags/1732454#1732454 –