I have a lot of strings in our MySQL database that have control characters such as ^M
. I want a regex that removes it in PHP, but leaves alone things such as new lines, eg: "\n".
I've tried the following:
preg_replace('/[\x00-\x09\x0B\x0C\x0E-\x1F\x7F]/', '', $bad);
This seems to leave it in place.
What's the best way to get rid of these control characters?