Q:

Escape \ without escaping group in regex

Mondays, however, how do I get a regex that will replace all \ that do not have a " after?
I have tried:
$toBeCleaned = preg_replace('/\\(?!")/',"\\\\",$toBeCleaned);

Which of course says:
preg_replace(): Compilation failed: unmatched parentheses at offset 5

Thing is I can get this to work on: http://www.solmetra.com/scripts/regex/index.php just fine.
However I modified it to:
$toBeCleaned = preg_replace('/\\\(?!")/',"\\\\",$toBeCleaned);

Which does not error out but at the same time, of course due to the escaping done, does not work.
I can't seem to comprehend on a Monday morning why I can't get it to do its job.

A:

After running @hank's regex by actually using a word to replace the text I found out my regex was working pefectly fine it just wasn't replacing correctly. So I changed it to:
$toBeCleaned = preg_replace('/\\\(?!")/',"\\\\\\",$toBeCleaned);

Which does actually work.
I am accepting this answer too because of the problems that can occur from using negated character classes as mentioned on this page: http://www.regular-expressions.info/charclass.html
I do hate Mondays.

