Re: Check for characters other than letters and numbers (for username)
| From: | CC Zona | Date: | Sat, 06 Jan 2001 10:28:13 +0000 |
| Subject: | Re: Check for characters other than letters and numbers (for username) | ||
| References: | 1 2 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-33028@lists.php.net to get a copy of this message | ||
In article <935r6q$c67$1@toye.p.sourceforge.net>, jaydub@bossanova.com
("Jeff Warrington") wrote:
> > is there a simple function to check for characters other than letters
> > and numbers? i'd like to verify a username is valid when they register.
> ereg("[a-zA-Z0-9]+",$string)
>
> or
>
> ereg("[[:alpha:][:digit:]]+",$string)
> or
> ereg("[[:alnum:]]+",$string)
Of course what that checks is whether the string contain one or more
characters that *are letters or numbers. If the goal is to check whether
the string contains one or more of characters other than those, perhaps
something like:
if(ereg([^a-zA-Z0-9]",$string)) {echo "Try again!";}
would be preferrable.
--
CC