in reply to Match all emails from all subdomains for a domain except one..

@addresses = <DATA>; chomp @addresses; for ( @addresses ) { if ( /@(?!bar.example.com$)/ ) { # Fill in really cool regexp here print "$_ : match\n"; } else { print "$_ : fail\n"; } } __END__ smith@example.com jones@example.com jones@foo.example.com jones@bar.example.com jones@bar.example.com.com jones@baz.example.com
Results:
smith@example.com : match jones@example.com : match jones@foo.example.com : match jones@bar.example.com : fail jones@bar.example.com.com : match jones@baz.example.com : match

--Bob Niederman, http://bob-n.com

Replies are listed 'Best First'.
Re: Re: Match all emails from all subdomains for a domain except one..
by ehdonhon (Curate) on Aug 09, 2003 at 00:13 UTC

    Sorry, I guess I didn't make it clear enough, it also needs to fail on anything that isn't example.com. So, "jones@otherdomain.com" should fail.

      Sorry, I guess I didn't make it clear enough,

      I'll say.... this is now beyond my RE skills...

      Why all in in one un-negated RE? Is this for a postfix rule or some-such?

      --Bob Niederman, http://bob-n.com
      ...it also needs to fail on anything that isn't example.com

      Then just move the parens a little bit, and make the specific subdomain optional...

      /@(?!bar\.)?example\.com$/

      Update: Oh well, that's why it's called "free advice"

        Testing would be good. Your change causes jones@foo.example.com, jones@bbar.example.com and jones@baz.example.com to fail.

        --Bob Niederman, http://bob-n.com