PHP preg_replace all but letters and numbers

If you want to remove all characters from a string using ascii range, this is one setup you can use. To modify see the HEX ascii values in this ascii table.

<?php
$text
= preg_replace('/[\x00-\x1F\x21-\x2F\x3A-\x40\x5B-\x60\x7B-\xBF]/u', '', $text); //ascii range keep characters and numbers
?>

<?php
//these are the ascii ranges:
\x00-\x1F
\x21-\x2F
\x3A-\x40
\x5B-\x60
\x7B-\xBF
?>
Knowledge keywords: