Skip site navigation (1)Skip section navigation (2)
Date:      Wed, 2 Jan 2002 09:46:34 -0800 
From:      Erin Fortenberry <efortenb@sdccd.cc.ca.us>
To:        "'doug@safeport.com'" <doug@safeport.com>
Cc:        freebsd-questions@FreeBSD.ORG
Subject:   RE: Regex Question - email matching
Message-ID:  <BBDEEDD2EB67D311A0240008C74B93453A8FCF@ntxmidcity.sdccd.cc.ca.us>

next in thread | raw e-mail | index | archive | help
The following works well for me.

Erin



&error('Bad email address.') unless &check_email;


sub check_email {

	my $email = $co->param('email');

	if ($email =~ /(@.*@)|(\.\.)|(@\.)|(\.@)|(^\.)/ || $email !~
/^.+\@(\[?)[a-zA-Z0-9\-\.]+\.([a-zA-Z0-9]+)(\]?)$/) {
		return 0;
	}
	else {
		return 1;
    }

};





> -----Original Message-----
> From: doug@safeport.com [mailto:doug@safeport.com]
> Sent: Wednesday, January 02, 2002 9:34 AM
> To: freebsd-questions@FreeBSD.ORG
> Subject: Regex Question - email matching
> 
> 
> I know this is impossible in general. I am looking for 
> something that matches
> the normal me@domain.tld. What I settled on so far is (in perl):
> 
> 	\w+\@\w+\.\w+
> 
> This is cool in that it is short, it matches things like
> first.last@host.domain.tld. It unfortunately also matches 
> me@name@domain.tld
> which I do not believe is valid. So my question: is there an 
> *easy* way to
> require exactly one "@".
> 
> Thanks for any pointers.
> 
> _____
> Douglas Denault
> doug@safeport.com
> Voice: 301-469-8766
>   Fax: 301-469-0601
> 
> 
> 
> To Unsubscribe: send mail to majordomo@FreeBSD.org
> with "unsubscribe freebsd-questions" in the body of the message
> 

To Unsubscribe: send mail to majordomo@FreeBSD.org
with "unsubscribe freebsd-questions" in the body of the message




Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?BBDEEDD2EB67D311A0240008C74B93453A8FCF>