I’m trying to replace \’ with ‘ but it won’t work
This is the text I want to replace from
Using Twitter\’s @Anywhere Service in
6 Steps
and this is the code
$tutorial = "Using Twitter\'s @Anywhere Service in 6 Steps ";
echo $tutorial."<br /><br />";
$tut_title = preg_replace("/\\'/", "'", $tutorial);
echo $tut_title;
You don’t need to bother with regular expressions for this. In this particular case, you can just use stripslashes.
You can also use
str_replace("\\'", "'", $tutorial);For future regex reference, though, you would need to double-escape the backslash:
$tut_title = preg_replace("/\\\\'/", "'", $tutorial);Why? because in your current form, you’re passing the pattern
/\'/to the regex engine, which is just trying to escape'