Re: check for alphanumeric characters

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



* John Nichel <john@xxxxxxxxxxxx>:
> Diana Castillo wrote:
> > what kind of a function can I use that will tell me whether a variable is 
> > alphanumeric (that is has only characters A-Z or 1-9 )?
>
> Something like this should work.  (untested)
>
> preg_match ( "/^([a-z]||[A-Z]||[0-9])+$/", $string )

It can be simpler than that, actually:

preg_match('/^[a-z0-9]+$/i', $string)

(tested and works)

-- 
Matthew Weier O'Phinney           | WEBSITES:
Webmaster and IT Specialist       | http://www.garden.org
National Gardening Association    | http://www.kidsgardening.com
802-863-5251 x156                 | http://nationalgardenmonth.org
mailto:matthew@xxxxxxxxxx         | http://vermontbotanical.org

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux