lime icon

Phosphorus and Lime

A Developer's Broadsheet

This blog has been deprecated. Please visit my new blog at klenwell.com/press.
PHP: alphanum regex
This should be instinct by now:

$_REGEX['alphanum'] = '%[^A-Za-z0-9]*%';


As used to remove all non-alphanumeric characters:

$_STRING['alphanum_only'] = preg_match($_REGEX['alphanum'], '', $string);


keywords: PHP, regex, alphanumeric, alphanum
The code will only tell you if the string is alphanumeric or not.

To actually remove the non-alphanumeric characters you have to use preg_replace instead of preg_match