RE: [PHP] regexps

From: Date: Wed, 08 Aug 2001 21:05:08 +0000
Subject: RE: [PHP] regexps
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-61911@lists.php.net to get a copy of this message
here are two regexps that might do what you want "\w" matches alphanum (1-9a-zA-z) IMO, the best way to check for non-alphanum chars is to check for "\W" (upper case is negation of alphanum, which will match only non-alphanum). if (preg_match('/^\w+$/', $data)) { print "entirely alphanum } if (preg_match('/\W+/', $data)) { print "Contains non-alphanum!!"; } > -----Original Message----- > From: Kurth Bemis [mailto:kurth@usaexpress.net] > Sent: Wednesday, August 08, 2001 4:43 PM > To: php-general@lists.php.net > Subject: [PHP] regexps > > > i need to find out if a string (user imputed) conatins numbers. I want > only a-zA-Z to be in a field. (their name for example....and city)...i > have the following however my regexps are VERY weak as i am a beginner. > > function validatetext($text){ > if (is_string($text)== 1){ > return "good"; > }else{ > return "bad"; > } > } > > ~kurth > > > -- > PHP General Mailing List (http://www.php.net/) > To unsubscribe, e-mail: php-general-unsubscribe@lists.php.net > For additional commands, e-mail: php-general-help@lists.php.net > To contact the list administrators, e-mail: php-list-admin@lists.php.net >

« previous php.general (#61911) next »