[thelist] PHP: is_numeric... that's the question...

Tris beertastic at gmail.com
Thu Jan 18 05:32:12 CST 2007

I'm rather enjoying this.. I've got 19 functions to write, and I've
allready turned some 10+ liners into 1 line!!!
learning is fun.!!

anyhoo, next I wanna check to see if a usercode is only numeric, and
1-8 characters long..

I tried this:
return preg_match("/\d{1,8}/", is_numeric($usercode));
but is there a way in regular expretions to exclude characters, so I
can say JUST return true if it's ONLY numbers...

I tried:
return preg_match("[^a-zA-Z][0-9]{1,8}", $usercode);
But it was accepted if there were any numbers in teh text.. that's bad!


On 18/01/07, Max Schwanekamp <lists at neptunewebworks.com> wrote:
> Tris wrote:
> > I went here:
> > http://www.phpbuilder.com/columns/dario19990616.php3
> > but could find no reference to the ' ! ' you have at the start and end
> > of your $pattern string...
> > can you let me know what they do..?
> The ! is just the regex pattern delimiter.  AFAIK it can be any regular
> character.  Most PHP coders use / or ! or #.  See the first paragraph on
> the PCRE page:
> http://www.php.net/manual/en/ref.pcre.php
> HTH!
> --
> Max Schwanekamp
> NeptuneWebworks.com
> 541-255-2171
> --
> * * Please support the community that supports you.  * *
> http://evolt.org/help_support_evolt/
> For unsubscribe and other options, including the Tip Harvester
> and archives of thelist go to: http://lists.evolt.org
> Workers of the Web, evolt !

When a person can no longer laugh at himself, it is time for others to
laugh at him.
Thomas Szasz

More information about the thelist mailing list