Hi Justin,
for the username, you can use:
if (!preg_match("/^[a-z0-9]*$/", $username)) {
// error
} else {
// ok
}
The ^ means start of the string, the characters between the [ and ] are ones
that we want, the * means however many times, and the $ means the end of the
line / string. So if there isn't a match against lower case letters and
numbers throughout the string (from start to finish), there's an error.
I'd advise you to go more complex with the email address.
James.
"Justin French" <[EMAIL PROTECTED]> wrote in message
[EMAIL PROTECTED]">news:[EMAIL PROTECTED]...
> hi all,
>
> two quick reg exp problems:
>
> one:
> $username must only contain a-z lowercase, 0-9, no spaces, no other
characters.
> what would the regexp be?
>
> if(ereg("????????????????", $username)) { $valid = "yes" } else { $valid
> = "no")
>
>
> two:
> i want to do a really small email validation, just to make sure the
> email probably right, as in:
> [EMAIL PROTECTED]
>
> what's the best reg exp to use.
>
>
> i'm aware there are email validating script out there, but I want to
> learn for myself
>
>
>
> many thanks in advance
>
>
> justin french
--
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]