I am trying to clear a string.
I need to allow only
- Upper / lower letters
- the numbers
- spaces, tabs, carriage returns
- these characters:
_-+*()[]!#?.,;:'"<>
Everything else must go bye. How should I do it? I have this one that works for letters, numbers and upper / lower case spaces. But I do not know how to account for tabs, carriage returns, or how to perform special characters?
$str = preg_replace('/[^a-z0-9 ]/i', '', $str);
source
share