RE: [PHP] Matching valid e-mail address
| From: | Jim Carey | Date: | Tue, 12 Sep 2000 12:25:07 +0000 |
| Subject: | RE: [PHP] Matching valid e-mail address | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-16333@lists.php.net to get a copy of this message | ||
a _ after the @ sign is actually an invalid email address, You can have them
before but not after
Jim Carey
> -----Original Message-----
> From: Tero Ripattila [mailto:tero.ripattila@nic.fi]
> Sent: Monday, 11 September 2000 7:42 PM
> To: php-general@lists.php.net
> Subject: [PHP] Matching valid e-mail address
>
>
> HI!
>
> I borrowed an example offered in this newsgroup some time ago and expanded
> it a little. I managed to get the function to accept an underscore (_)
> before the @-sing, but can't make it acceptable by the function after the
> @-sign.
>
> Could some Perl-guru give me a helping hand ?-)
>
> Here is the script:
> function check_email_syntax($email) {
> if( eregi("(@.*@)|(\.\.)|(@\.)|(\.@)|(^\.)", $email) ||
>
> !eregi("^.+\@(\[?)[-a-zA-Z0-9\.]+\.([a-zA-Z]{2,3}|[0-9]{1,3})(\]?)$",
> $email)) {
> return(false);
> }
> else {
> list($user, $domain) = explode("@", $email);
>
> if ( (!eregi("^[a-zA-Z0-9\_\.\-]+$", $user)) ||
> (!eregi("^[a-zA-Z0-9\_\.\-]+$", $domain))) {
> return(false);
> }
> else {
> return(true);
> }
> }
> }
>
> Tero Ripattila
>
>
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, e-mail: php-general-unsubscribe@lists.php.net
> For additional commands, e-mail: php-general-help@lists.php.net
> To contact the list administrators, e-mail: php-list-admin@lists.php.net
>