Possible Duplicate:
php preg_replace \
I am trying to replace all occurances of the “\” character with “_c” using preg_replace.
Here is some code I have tried:
$outputStr=preg_replace('/\/','_c',$inputStr);
$outputStr=preg_replace('/\\/','_c',$inputStr);
But the $outputStr ends up as NULL in both cases. What is the correct regular expression to get the “\” character?
You need to escape the slash in your string and your regex:
See http://de3.php.net/preg_replace. e.g.