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

From: Date: Fri, 14 Nov 2003 11:18:56 +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-169631@lists.php.net to get a copy of this message
Dave -- ..and then Dave G said... % % > ... escaping isn't necessary. % % Thanks so much for all the helpful advice! You're quite welcome :-) % Okay, included the + character, and removed the escaping. And I know I'm Good! % 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 Sounds good. Note that preg_match will use the same regexp syntax, too. % 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, Yep. % won't PHP think I'm looking for a range from nothing to nothing? Or is If you put the hyphen between two things, yes. If not, no. % it clever enough to figure out what's going on? It's not only a PHP thing; just about any *NIX tool or programming language that understands extended regexps at all will behave that way. I truly wish that I could point you to a canonical reference on the matter, but such a thing escapes me. I'm fairly sure you'd be able to find it -- or a reference to it -- within the GNU space, so perhaps the man page for egrep or such would help. I did a quick google search and found http://www.opengroup.org/onlinepubs/7908799/xbd/re.html which may be helpful. In addition, there is a regex package by Henry Spencer which seems to be everyone's reference point. % (!eregi('^[a-zA-Z0-9+_.-]+@[a-zA-Z0-9-]+.[a-zA-Z0-9.-]+$', $email) % % -- % Cheers! % Dave G % ml@autotelic.com HTH & HAND :-D -- David T-G * There is too much animal courage in (play) davidtg@justpickone.org * society and not sufficient moral courage. (work) davidtgwork@justpickone.org -- Mary Baker Eddy, "Science and Health" http://justpickone.org/davidtg/ Shpx gur Pbzzhavpngvbaf Qrprapl Npg!

« previous php.general (#169631) next »