正则表达式匹配除< p>之外的所有HTML标记和标记内容和< / p> [英] Regex to match all HTML tags and tag content except <p> and </p>
问题描述
我正在寻找一个regex来匹配所有HTML标签,除了< p>
和< / p>
包括标记内容。我在ColdFusion中开发。
有一个较早的帖子关于除< p>
和< / p> ;
,但我需要抓取标签之间的一切。例如,以下内容应完全匹配:
< a href =http://www.google.com > Google< / a>
和
< em>这里有一些文字< / em>
但不包括
< p>这里有一些文字和标签< / p>有关如何完成此任务的任何想法吗? h2_lin>解决方案使用正则表达式解析HTML非常困难和痛苦。
你最好使用某种DOM-并找到您需要的元素。
I am looking for a regex to match all HTML tags, except <p>
and </p>
that includes the tag content. I am developing in ColdFusion.
There was an earlier post about matching tags except <p>
and </p>
, but I need to grab everything between the tags as well. For instance, the following should match in their entirety:
<a href="http://www.google.com">Google</a>
and
<em>Some text here</em>
but not
<p>Some text and tags here</p>
Any ideas on how to accomplish this?
解决方案 Parsing HTML using regular expressions is very very hard and painful.
You're better off using some sort of DOM-based parser and finding the elements you need.
这篇关于正则表达式匹配除< p>之外的所有HTML标记和标记内容和< / p>的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!