PHP Remove all but allowed characters or disallowed chars
The following will remove all characters but those allowed.
PHP
$str = preg_replace('@[^a-zA-Z0-9_:;\(\)\?\|\&=!<>+*/\%-]@', '', $str);
The following will remove all characters but those allowed.
$str = preg_replace('@[^a-zA-Z0-9_:;\(\)\?\|\&=!<>+*/\%-]@', '', $str);