Why would this eregi() function not work?

From: Date: Fri, 14 Nov 2003 03:35:48 +0000
Subject: Why would this eregi() function not work?
Groups: php.general 
Request: Send a blank email to php-general+get-169613@lists.php.net to get a copy of this message
PHP Gurus, I have an eregi() function that I'm using to validate emails that users enter into a form. I pretty much took it directly from the book "PHP and MySQL Web Development". It looks like this: (!eregi('^[a-zA-Z0-9_\-\.]+@[a-zA-Z0-9\-]+\.[a-zA-Z0-9\-\.]+$', $email) For the most part it's working fine. But recently a user tried to enter in his email address and it got rejected by this script. After a little experimentation, it looks like it's the hyphen in the first part of his address that's causing it to be rejected. His email address looks like: f-takxxx@xxx.xxxxxxxx.xx.xx If I remove the hyphen, like so: ftakxxx@xxx.xxxxxxxx.xx.xx Then it passes. Looking at my eregi() function, I've included hyphens as a valid character, and escaped them out with slashes in order that they work within the square brackets. Why would this email be rejected? -- Cheers! Dave G ml@autotelic.com

« previous php.general (#169613) next »