RE: [PHP] Silly RegEx - Looks good to me
| From: | Jason Stechschulte | Date: | Fri, 15 Dec 2000 17:09:23 +0000 |
| Subject: | RE: [PHP] Silly RegEx - Looks good to me | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-30537@lists.php.net to get a copy of this message | ||
I could be wrong, but I think when you put the ^ inside of the
[]'s that you are saying not the following characters. So
basically you are saying if the string does not contain
alphanumeric characters. I could be wrong though, its happened
before.
Jason Stechschulte
jpstech@nc.edu
Hey,
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)) {
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.
Jason