Re: regular expression to capture invalid emails
From: Matt Garrish (matthew.garrish_at_sympatico.ca)
Date: 02/29/04
- Next message: Sam Holden: "Re: regular expression to capture invalid emails"
- Previous message: anonymous: "Re: regular expression to capture invalid emails"
- In reply to: anonymous: "regular expression to capture invalid emails"
- Next in thread: anonymous: "Re: regular expression to capture invalid emails"
- Reply: anonymous: "Re: regular expression to capture invalid emails"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Date: Sat, 28 Feb 2004 22:53:38 -0500
"anonymous" <anonymous@anon.com> wrote in message
news:k5mdnRSQd-tzw9zdRVn-sA@mminternet.net...
> Ok, what I want to do is simple. I want to create a regular expression
that
> matches any email address that ends in two characters like
antyhing@home.tv
> but not anything@home.us my working regexp: (.*)@(.*)\.(\w){2}$
> how do I change it so it doesn't match .us? I want to do it all in one
> expression for specific reasons.
>
Assuming you're using a module like Email::Valid to check the validity of
the address first (no comments on all the ways your check above would fail),
you could just check that the address doesn't end with "us" or 3+
characters:
next if $email =~ /\.(us|\w{3,})$/i;
Matt
- Next message: Sam Holden: "Re: regular expression to capture invalid emails"
- Previous message: anonymous: "Re: regular expression to capture invalid emails"
- In reply to: anonymous: "regular expression to capture invalid emails"
- Next in thread: anonymous: "Re: regular expression to capture invalid emails"
- Reply: anonymous: "Re: regular expression to capture invalid emails"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Relevant Pages
|