Re: Alphanumeric Strings

From: Date: Thu, 14 Sep 2000 23:20:03 +0000
Subject: Re: Alphanumeric Strings
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-16864@lists.php.net to get a copy of this message
On Thu, 14 Sep 2000, Jason Granum wrote: > I can't seem to find the regex I'm looking for here. > If anyone could point me in the right direction. > I'm trying to see if a string contains ONLY alphanumeric characters. > Is there an easy regex to find this out? Tnx > I think the following should do it: if (!eregi("^[a-zA-z]+$",$variable)) { echo "Variable contains non-alphabetic characters."; exit; } This will require at least one character. Use an asterisk (*) if you don't mind an empty string. John

« previous php.general (#16864) next »