Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
menu search
person
Welcome To Ask or Share your Answers For Others

Categories

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 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!

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
222 views
Welcome To Ask or Share your Answers For Others

1 Answer

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

Done.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
...