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:[EMAIL PROTECTED]]
> Sent: Wednesday, August 08, 2001 4:43 PM
> To: [EMAIL PROTECTED]
> 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: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
> To contact the list administrators, e-mail: [EMAIL PROTECTED]
>
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]