Re: Why would this eregi() function not work?
| From: | David T-G | Date: | Fri, 14 Nov 2003 04:06:32 +0000 |
| Subject: | Re: Why would this eregi() function not work? | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-169616@lists.php.net to get a copy of this message | ||
Dave --
..and then Dave G said...
%
% 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)
1) Constructing an all-compatible email expression is darned near
impossible. See the archives for a recent discussion of this.
2) Sure enough, you don't allow "+" extensions in yours. Neener neener :-)
3) You might check out preg_match, which the manual says is often faster
than ereg().
4) To include '-' in a range list, put it last in the range.
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!