You are here: Re: How can I know if a string is alphanumeric? « PHP Programming Language « IT news, forums, messages
Re: How can I know if a string is alphanumeric?

Posted by Andy Hassall on 02/16/06 01:18

On Thu, 9 Feb 2006 14:02:04 -0800, "Jim Michaels" <jmichae3@nospam.yahoo.com>
wrote:

>>> How can I know if a string only has alfanumeric chars?
>
>give him an example!
>
>preg_match('/^[\w\d]$/', $string);

\w includes more than alphanumeric (it includes underscore), but includes all
of \d.

Alternatives could be:

/^[a-zA-Z\d]+$/

... or even ...

/^[^\W_]+$/

... for ASCII definitions of "alphanumeric", anyway.

--
Andy Hassall :: andy@andyh.co.uk :: http://www.andyh.co.uk
http://www.andyhsoftware.co.uk/space :: disk and FTP usage analysis tool

 

Navigation:

[Reply to this message]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация