|
From: Frank Seitz on 7 May 2008 05:09 Abigail wrote: > _ > Samik R. (samik(a)frKKshKll.org) wrote on VCCCLXIII September MCMXCIII in > <URL:news:fvr60f$pqd$1(a)aioe.org>: > :) Hello, > :) I use the following regular expression to catch typical invalid email > :) addresses: > :) ------------ > :) my @Email=("sam._\@abc.org", "sam_.\@abc.org", "sam_.\@abc.org"); > :) foreach (@Email) > :) { > :) > :) if(/^[A-z0-9]+([_\.][A-z0-9\-]+)*[@][A-z0-9_\-]+([.][A-z0-9_\-]+)?\.[A-z]{2,3}$/) > :) { print "$_ is a valid email id\n"; } > :) else > :) { print "$_ is an invalid email id\n"; } > :) } > :) ------------- > :) > :) This expression does not catch the above 3 emails in the array (the > :) program says that they are valid emails). > :) > :) Can someone help me to discard these three? > > Sure. > > if (/_/) { > print "$_ is invalid"; > } > else { > print "$_ is valid"; > } An e-mail address with _ (or ._ or _.) isn't invalid, AFAIK. Frank -- Dipl.-Inform. Frank Seitz; http://www.fseitz.de/ Anwendungen f�r Ihr Internet und Intranet Tel: 04103/180301; Fax: -02; Industriestr. 31, 22880 Wedel
From: Abigail on 7 May 2008 06:00 _ Frank Seitz (devnull4711(a)web.de) wrote on VCCCLXIII September MCMXCIII in <URL:news:68d9vaF2slnr9U1(a)mid.individual.net>: ;; Abigail wrote: ;; > _ ;; > Samik R. (samik(a)frKKshKll.org) wrote on VCCCLXIII September MCMXCIII in ;; > <URL:news:fvr60f$pqd$1(a)aioe.org>: ;; > :) Hello, ;; > :) I use the following regular expression to catch typical invalid email ;; > :) addresses: ;; > :) ------------ ;; > :) my @Email=("sam._\@abc.org", "sam_.\@abc.org", "sam_.\@abc.org"); ;; > :) foreach (@Email) ;; > :) { ;; > :) ;; > :) if(/^[A-z0-9]+([_\.][A-z0-9\-]+)*[@][A-z0-9_\-]+([.][A-z0-9_\-]+)?\.[A-z]{2,3}$/) ;; > :) { print "$_ is a valid email id\n"; } ;; > :) else ;; > :) { print "$_ is an invalid email id\n"; } ;; > :) } ;; > :) ------------- ;; > :) ;; > :) This expression does not catch the above 3 emails in the array (the ;; > :) program says that they are valid emails). ;; > :) ;; > :) Can someone help me to discard these three? ;; > ;; > Sure. ;; > ;; > if (/_/) { ;; > print "$_ is invalid"; ;; > } ;; > else { ;; > print "$_ is valid"; ;; > } ;; ;; An e-mail address with _ (or ._ or _.) isn't invalid, AFAIK. But that wasn't what he asked. He wanted to filter out three particular email addresses. Abigail -- my $qr = qr/^.+?(;).+?\1|;Just another Perl Hacker;|;.+$/; $qr =~ s/$qr//g; print $qr, "\n";
First
|
Prev
|
Pages: 1 2 Prev: Identification of which line causing regex problem Next: perl GD Image resolution problem |