扫码关注官方订阅号
例如:替换为
求处理办法。
preg_replace 正则表达式的搜索和替换
preg_replace
使用preg_replace, 写了个简单的例子:
$b = ' <a href="http://tool.chinaz.com/" title="fish link">df</a> <a href="http://tool.chinaz.com/" title="no match">df</a> <a href="http://tool.chinaz.com/" title="fish link">df</a> '; var_dump(preg_replace('/<a.*title="fish link">/', '<a href="http://bbb.com" title="fish link">', $b));
output:
string(157) " <a href="http://bbb.com" title="fish link">df</a> <a href="http://tool.chinaz.com/" title="no match">df</a> <a href="http://bbb.com" title="fish link">df</a> "
微信扫码关注PHP中文网服务号
QQ扫码加入技术交流群
扫描下载App
Copyright 2014-2025 https://www.php.cn/ All Rights Reserved | php.cn | 湘ICP备2023035733号
PHP学习
技术支持
返回顶部
preg_replace
正则表达式的搜索和替换使用
preg_replace
, 写了个简单的例子:output: