ok, that was my problem.... Was using ereg... All the places I read about
how to do regular expressions (book, online...) did NOT clarify that \w and
such would need preg.. Thanks!

""Simon Garner"" <[EMAIL PROTECTED]> wrote in message
022d01c09fa6$a2bbd460$[EMAIL PROTECTED]">news:022d01c09fa6$a2bbd460$[EMAIL PROTECTED]...
> From: "Dan Watt" <[EMAIL PROTECTED]>
>
> > Im trying to build a user login system, and when there is a new user, I
> need
> > to validate that they are usign using word characters ([0-9A-Za-z_] or
> > \w)... I have TRIED MANY different regular expressions to test this, but
> > none work. This seems so simple but I am missing something. I need a
> > expression that returs true ONLY if ALL the characters match \w .... Any
> > help would be appreciated.
> >
> >
>
>
> <?php
>     $username = "johnny";
>
>     if (!eregi("[^A-Z0-9_-]", $username))
>     {
>         echo "username OK";
>     }
>     else
>     {
>         echo "bad username!";
>     }
> ?>
>
> Assuming you only want letters, numbers, underscores or hyphens. If you
> really want \w you would need to use preg instead of ereg, and then you
need
> PCRE support in PHP. Or you could use ereg's character classes, I think
the
> pattern would look like: "[^[:alphanum:]]". However you are probably
better
> off using an explicit set of characters as I have shown, so that it is
> obvious what is and is not allowed.
>
>
> Cheers
>
> Simon Garner
>
>
>
> --
> 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]

Reply via email to