Functions
ereg_ * (POSIX) has been deprecated for a long time. You should not use these methods.
According to POSIX, Bracket Expressions [:cntrl:]
allows the ASCII range [\x00-\x1F\x7F]
(or unicode \p{Cc}
) and [:space:]
allows [ \t\r\n\v\f]
. Using asciitable.com to eliminate these characters, you will leave an exception list [\x20\x09-\x0D]
. Performing the math, you are left with [\x00-\x08\x0E-\x1F\x7F]
. and this leaves you with the following: PHP 5.3 and compatibility with enhancement, sanitation:
$message = preg_replace('/[\x00-\x08\x0E-\x1F\x7F]+/', '', $message);
Please note that VT
(Vertical Tab) and FF
(Feed Channel, New Page) are also saved. Depending on your situation, you can also remove them:
$message = preg_replace('/[\x00-\x08\x0E-\x1F\x7F\x0A\x0C]+/', '', $message);
source share