   [web] Whitelisting form input in PHP
  Got another question, guys :)I'm trying to come up with a way to strip a string of all characters other than those I have added to a whitelist. PHP doesn't seem to have any simple way to do this. Only thing I've come up with so far is looping through each individual character in the string and comparing it to every character on the whitelist, which seems kinda clunky. Any ideas?   
  I trust you have a good reason to do this. ;)$text = preg_replace('/[^a-z0-9]/i', "", $text);The characters in [] are what you are matching. The initial ^ means "not". You can use some ranges like a-z and 0-9. Note that some characters are reserved and you may have to put a backslash \ in front of them. The two /'s mark the beginning and end of the expression. (You can use any char you would like for that.) The trailing "i" is for case insensitivity.   ;  Hehe, just what I needed. Thank you very much.   