求一正则表达式
求一正则表达式替换
baidu
如上字符串中标签外的baidu 为baidu
------解决方案--------------------
- PHP code
$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
飘走...