Re: Why would this eregi() function not work?

From: Date: Fri, 14 Nov 2003 09:18:45 +0000
Subject: Re: Why would this eregi() function not work?
References: 1 2  Groups: php.general 
Request: Send a blank email to php-general+get-169625@lists.php.net to get a copy of this message
On Fri, Nov 14, 2003 at 04:32:35PM +0900, Dave G wrote: : : > ... escaping isn't necessary. : : Thanks so much for all the helpful advice! : Okay, included the + character, and removed the escaping. And I know I'm : supposed to checking into preg_match, but I'm looking at this as an : opportunity to learn about regular expressions, so I still have a : question. I'm confused why hyphens wouldn't still need escaping. Hyphens : are used to express a range of characters. If there's a hyphen there, : won't PHP think I'm looking for a range from nothing to nothing? Or is : it clever enough to figure out what's going on? : (!eregi('^[a-zA-Z0-9+_.-]+@[a-zA-Z0-9-]+.[a-zA-Z0-9.-]+$', $email) The last part of your pattern needs to be changed because it allows for a top-level domain to contain numbers and hyphens. Currently, such a thing does not exist. Also, the 2nd part of your pattern allows for a 2nd-level domain to start and end with a hyphen, which is also disallowed.

« previous php.general (#169625) next »