I do not want to use stripslashes() because I only want to replace "\\" with "\".
I tried preg_replace("/\\\\/", "\\", '2\\sin(\\pi s)\\Gamma(s)\\zeta(s) = i\\oint_C \\frac{-x^{s-1}}{e^x -1} \\mathrm{d}x');
Which to my disapointment returns: 2\\sin(\\pi s)\\Gamma(s)\\zeta(s) = i\\oint_C \\frac{-x^{s-1}}{e^x -1} \\mathrm{d}x
Various online regex testers indicate that the above should work. Why is it not?
$a = preg_replace(...$a)or are you only calling preg_replace without actually saving its result?preg_replace('/\\\\/', '\\', '2\\sin(...');(single quotes). Then read up onstr_replace(), egexes are the wrong tool for the job.