求过滤alt的正则表达式解决办法
时间:2021-07-01 10:21:17
帮助过:3人阅读
求过滤alt的正则表达式
求PHP过滤alt的正则表达式,alt有三种情况,要求都能过滤掉
alt="https://www.gxlcms.com/xxxxhttps://www.gxlcms.com/xxxxhttps://www.gxlcms.com/xxxx"
alt='https://www.gxlcms.com/xxxxhttps://www.gxlcms.com/xxxxhttps://www.gxlcms.com/xxxx'
alt=https://www.gxlcms.com/xxxxhttps://www.gxlcms.com/xxxxhttps://www.gxlcms.com/xxxx
要求能过滤掉以上三种情况的。
示例:
……
要求能过滤各种情况,又不会过滤其它内容。谢谢。
正则表达式
php
分享到:
------解决方案--------------------我知道我那个正则有点问题,加那个 \b 是不得已而为之
不过既然能满足你示例的数据,那也就可以了。
你总不能让我去罗列一起可能出现的情况吧?那要你干什么呢?
$s =<<< TXT










TXT;
echo preg_replace('/alt=([\'"]?).+?\1(\s
------解决方案--------------------
>)/is', '$2', $s);
