| Special Characters Is there a PHP function that searches for only special chars? |
d40sithui

msg:3260438 | 3:52 pm on Feb 22, 2007 (gmt 0) | ~`!@#$%^&*()_-+=\][{}¦:;"'?/>.<, does anyone know of a function in PHP (if any) that finds only special characters? -khanh
|
cmarshall

msg:3260443 | 3:58 pm on Feb 22, 2007 (gmt 0) | | ~`!@#$%^&*()_-+=\][{}¦:;"'?/>.<, does anyone know of a function in PHP (if any) that finds only special characters? |
| preg_match [us3.php.net] ( "/~`!@#$%^&*()_-+= \\][{}¦:;"'?\/>.<,/", $string ); (Note the additional backslashes -actually, you'll need more than them. There's all kinds of special regex characters in there. Use preg_quote [us3.php.net] to scrub the regex.) So it might look like | preg_match("/".preg_quote("~`!@#$%^&*()_-+=\\][{}¦:;\"'?/>.<,","/")."/", $string); |
|
|
mcibor

msg:3260454 | 4:13 pm on Feb 22, 2007 (gmt 0) | I would use negation query: preg_match ( "@[^a-z0-9 ]+@i", $string ); It will also find line breaks
|
henry0

msg:3260613 | 6:37 pm on Feb 22, 2007 (gmt 0) | As mcibor shows it is better to check for what's allowed than the reverse you will have no problem at selecting what you agree to get and might very often forget a few items to disallow.
|
d40sithui

msg:3264578 | 7:18 pm on Feb 26, 2007 (gmt 0) | thanks for the help guys! -khanh
|
|
|