开发者

Transform ereg_replace to preg_replace

can someone transform this ereg_replace expression to preg_replace?

$string = mb_ereg_replace('([ -\.,\+\?\(\)\$\[\];_=])'
                         .$oldvalue.'([ -\.,\+\?\(\)\$\[\];_=])',"\\1"  
                         .$newvalue."\\2",$string);

Basically it searches a string ($oldvalue) which is preceded by space or dash or fullstop or plus sign开发者_Python百科 or parenthesis or brackets or question-mark or equal sign and is followed by one of these too and transforms it to (whatever was preceding)$newvalue(whatever was following).

I need to switch to preg_replace due to technical limitations, I hope someone can help!

Thank you!


$string = preg_replace('([ -\.,\+\?\(\)\$\[\];_=])' 
                     .$oldvalue.'([ -\.,\+\?\(\)\$\[\];_=])',"$1"   
                     .$newvalue."$2",$string); 

Done.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜