时间:2021-07-01 10:21:17 帮助过:26人阅读
$s = 'baid,baidu,baidu,google,baidu baidu sdfsdf www.baidu.com '; echo preg_replace("/(?\\1",$s);
------解决方案--------------------
$search = array("/(.*)([^\.]baidu[^\.])(.*)/", "/(.*)([^\.]baid[^\.])(.*)/", "/(.*)([^\.]google[^\.])(.*)/");
$replace = "\$1 baidu $3";
$str = ' baidu baid 12312 google ';
$res = preg_replace( $search, $replace, $str );
exit($res);
------解决方案--------------------
貌似PHP里有反向预查,那样的话,很简单的就可以解决了...:D
飘走...