$test="превед всем нах 123 hack"; $test = preg_replace("/[^a-zA-Z0-9 -_]/i", "", $test); echo $test; //вывод 123 hack