PHP正则表达式删除HTML文档中的标签 [英] PHP regular expression to remove tags in HTML document

查看:122
本文介绍了PHP正则表达式删除HTML文档中的标签的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

说我有以下文字

..(content).............
<A HREF="http://foo.com/content" >blah blah blah </A>
...(continue content)...

我想删除链接,也想删除标签(同时保持文本之间).如何使用正则表达式执行此操作(因为所有URL都不同)

I want to delete the link and I want to delete the tag (while keeping the text in between). How do I do this with a regular expression (since the URLs will all be different)

非常感谢

推荐答案

请尽可能避免使用正则表达式, strip_tags() simplexml ,具体取决于您的字符串.

Avoid regular expressions whenever you can, especially when processing xml. In this case you can use strip_tags() or simplexml, depending on your string.

这篇关于PHP正则表达式删除HTML文档中的标签的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆