Date: Wed, 02 Jan 2002 17:22:22 -0500 From: Simon Morton <simon.morton@verizon.net> To: freebsd-questions@FreeBSD.ORG Subject: Re: Regex Question - email matching Message-ID: <3C33881E.9030506@verizon.net> References: <200201021839.g02IdLG68388@lurza.secnetix.de>
next in thread | previous in thread | raw e-mail | index | archive | help
Don't worry, I won't be filtering any email addresses using this code. I just typed it in off the top of my head as an improvement over the regexp than was originally posted. Not surprising that a couple of the finer points of RFC 2822 escaped me ;-) The "correct" regexp for validating email addresses is left as an exercise for the reader. Simon Oliver Fromme wrote: > Simon Morton <simon.morton@verizon.net> wrote: > > if ( $email =~ /^([\w\.\-]+)\@([\w\.\-]+)\.([[:alpha:]]+)$/ ) { > > [...] > > } else { > > print "Invalid email address\n"; > > Then you would be rejecting a lot of valid addresses. > For example, they can contain "+". On the other hand, > it would accept "_" in domain names which is illegal. > > Please -- if someone is accepting or rejecting email > addresses based on some regular expression, _PLEASE_ > read RFC 2822 first, and in particular section 3.4 > titled "address specification". Otherwise you might > cause some trouble and grief to your users. > > The format of valid email addresses is more complicted > than many people think. > > Regards > Oliver > > -- http://www.SimonMorton.com smorton at acm dot org \rm -rf /bin/laden 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?3C33881E.9030506>