CGI/Perl Guide | Learning Center | Forums | Advertise | Login
Site Search: in

  Main Index MAIN
Search Posts SEARCH
Who's Online WHO'S
Log in LOG

Home: Perl Programming Help: Regular Expressions:
pattern match


martin barlow
New User

Apr 14, 2005, 5:25 PM

Post #1 of 4 (9654 views)
pattern match Can't Post

The pattern will contain one email address.

Emails should not be matched unless:
They are from a certain domain (say
AND not from a two specific emails (say and (not match) (match) (not match) (not match)

I am sure there is any easy way, but its a bit beyond my regular expression skills! Thanks for any solutions.Cool

Thaumaturge / Moderator

Apr 17, 2005, 9:54 AM

Post #2 of 4 (9644 views)
Re: [martin barlow] pattern match [In reply to] Can't Post

It's probably easier in this case to split the email address into local part and domain name (by splitting on @) and then doing string comparison.


use strict;
use warnings;

my %match_domain = ('' => 1);
my %nomatch_name = (john => 1,
david => 1);

while (<DATA>) {
my ($local, $domain) = split /@/;

print "$_ - ";
if ($match_domain{$domain} and not $nomatch_name{$local}) {
print "Match\n";
} else {
print "No Match\n";


Regexes aren't always the best solution to text matching problems :)

Dave Cross, Perl Hacker, Trainer and Writer
Get more help at Perl Monks

martin barlow
New User

Apr 20, 2005, 4:46 AM

Post #3 of 4 (9622 views)
Re: [davorg] pattern match [In reply to] Can't Post


I agree that the simple solution is often the best. Your solution is elegant. Unfortunately in my case i don't have access to proper PERL from the interface.

I need this for a CRM which allows me to specify PCRE's to match email addresses and deal with them accordingly.

I'll mull over this problem a bit longer......


(This post was edited by martin barlow on Apr 20, 2005, 4:49 AM)

martin barlow
New User

May 18, 2005, 10:05 PM

Post #4 of 4 (9299 views)
Re: [martin barlow] pattern match [In reply to] Can't Post


look good?

(This post was edited by martin barlow on May 18, 2005, 10:06 PM)


Search for (options) Powered by Gossamer Forum v.1.2.0

Web Applications & Managed Hosting Powered by Gossamer Threads
Visit our Mailing List Archives