php - Replace (ss) with something else -


i have problem in php replacing (ss) in string.

$string = 'i want new (ss) now!'; $newstring = preg_replace('\(ss\)', 'car', $string); 

i expecting $newstring become:

i want new car now!

what doing wrong here ?

use str_replace

$string = 'i want new (ss) now!'; $newstring = str_replace('(ss)', 'car', $string); 

example http://codepad.org/2wcytl8e

output

i want new car now!

edit

example preg_replace

http://codepad.org/cfmsdtjr

$string = 'i want new (ss) now!'; $newstring = preg_replace('$\(ss\)$', 'car', $string); 

output

i want new car now!


Comments

Popular posts from this blog

node.js - Bad Request - node js ajax post -

Why does Ruby on Rails generate add a blank line to the end of a file? -

keyboard - Smiles and long press feature in Android -