Re: Silly RegEx - Looks good to me
| From: | Mathieu Poumeyrol | Date: | Fri, 15 Dec 2000 17:16:49 +0000 |
| Subject: | Re: Silly RegEx - Looks good to me | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-30541@lists.php.net to get a copy of this message | ||
On Fri, Dec 15, 2000, JB wrote:
> Here's an easy one for someone to field. I do these regex validations in just about every
> piece of code I write with forms, so I'm a little baffeled why it doesn't work, cus it
> looks good to me.
>
> if ($name=="" || eregi("[^a-z0-9\.-][[:space:]]", $name)) {
^^
try if ($name=="" || eregi("[^a-z0-9\.[:space:]-]", $name)) {
> print "ERROR, Please fill out this field, and use alphanumerical characters
> only!";
> }
>
> Basically if the field is left empty or contains anything but alphanumeric hypen period or
> space it should print the error message.
> However, entering something like !@#$%^&*(+_* passes right through the regex.. no error
> message is displayed. Whats the prob here? Thanks.
--
Mathieu Poumeyrol