Convert ereg_replace to preg_replace

can someone convert this ereg_replace expression to preg_replace?

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

Basically, he searches for a string ($ oldvalue) preceded by a space or dash or a full or plus sign or brackets or brackets or a question mark or equal sign, followed by one of them and transforms it (regardless of what was previous ) $ newvalue (whatever).

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

Thanks!

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

Done.

0
source

Source: https://habr.com/ru/post/1391917/


All Articles