简体   繁体   English

PHP REGEX排除某些标签?

[英]PHP REGEX Exclude Certain Tags?

For REGEX, I am wondering how I would clear all HTML tags entered except for the simple ones, such as <a>, <b>, <i>, <pre> . 对于REGEX,我想知道如何清除所有输入的HTML标记(简单标记除外),例如<a>, <b>, <i>, <pre> I know that I can use this regex to exclude all html charicters, but I am not sure how I would go about only removing some, and deleting the others while conserving the content inside. 我知道我可以使用此正则表达式排除所有html字符,但是我不确定如何在保留内部内容的同时只删除其中一些,删除其他字符。 Thanks! 谢谢!

See the second parameter in : 请参阅中的第二个参数:

http://php.net/strip_tags http://php.net/strip_tags

Essentially, you can call this function and list the tags you don't' want to be stripped. 本质上,您可以调用此函数并列出您不想剥离的标签。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM