From owner-freebsd-questions Wed Jan 2 9:45:41 2002 Delivered-To: freebsd-questions@freebsd.org Received: from intergate.sdccd.cc.ca.us (intergate.sdccd.cc.ca.us [209.129.16.2]) by hub.freebsd.org (Postfix) with ESMTP id CEA6037B41A for ; Wed, 2 Jan 2002 09:45:37 -0800 (PST) Received: from ntxdistrict.sdccd.cc.ca.us (ntxdistrict.sdccd.cc.ca.us [10.1.100.1]) by intergate.sdccd.cc.ca.us (8.9.1a/8.9.1) with ESMTP id JAA17685; Wed, 2 Jan 2002 09:39:53 -0800 (PST) Received: by ntxdistrict.sdccd.cc.ca.us with Internet Mail Service (5.5.2654.89) id ; Wed, 2 Jan 2002 09:46:47 -0800 Message-ID: From: Erin Fortenberry To: "'doug@safeport.com'" Cc: freebsd-questions@FreeBSD.ORG Subject: RE: Regex Question - email matching Date: Wed, 2 Jan 2002 09:46:34 -0800 MIME-Version: 1.0 X-Mailer: Internet Mail Service (5.5.2654.89) Content-Type: text/plain; charset="iso-8859-1" Sender: owner-freebsd-questions@FreeBSD.ORG Precedence: bulk List-ID: List-Archive: (Web Archive) List-Help: (List Instructions) List-Subscribe: List-Unsubscribe: X-Loop: FreeBSD.ORG 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