Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/237.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Php 用正则表达式替换HTML实体_Php_Regex_Preg Replace - Fatal编程技术网

Php 用正则表达式替换HTML实体

Php 用正则表达式替换HTML实体,php,regex,preg-replace,Php,Regex,Preg Replace,我想要一个PHP正则表达式来查找所有HTML实体,例如“br/br/.etc.”,以便从长字符串中删除它们。尝试使用strip\u tags函数,此处不需要正则表达式此函数删除alpha、decimal和hex HTML实体: $text=preg_replace('/&(?[a-z\d]+||||#d+|x[a-f\d]+);/i','','$text); 尝试使用此正则表达式。。。[^\s]*一个捕获了大量其他的废话 $text = preg_replace("/&(?:[a-z0-

我想要一个PHP正则表达式来查找所有HTML实体,例如
“br/br/.etc.”
,以便从长字符串中删除它们。

尝试使用strip\u tags函数,此处不需要正则表达式此函数删除alpha、decimal和hex HTML实体:

$text=preg_replace('/&(?[a-z\d]+||||#d+|x[a-f\d]+);/i','','$text);

尝试使用此正则表达式。。。[^\s]*一个捕获了大量其他的废话

$text = preg_replace("/&(?:[a-z0-9]{2,8}|#[0-9]{2,3}+);/i", '', $text);

完全删除或替换为他们的角色值?你有没有尝试过自己解决它,如果有,你想出了什么?这个答案;这已经有一个经过测试的功能,不要为自己做更多的工作-1、
strip\u tags()
删除标记,而不是html实体,例如