Re: regular expression to capture invalid emails

From: Matt Garrish (matthew.garrish_at_sympatico.ca)
Date: 02/29/04


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



Relevant Pages

  • Re: Regular Expression Function
    ... I want a regular expression to compare sentences and then rate them as ... I have an array with a list of other phrases like so... ... characters will throw things off. ... "In an hour the system will go down for maintenance". ...
    (alt.php)
  • Re: Regular Expression Function
    ... I want a regular expression to compare sentences and then rate them as ... I have an array with a list of other phrases like so.. ... These will be stripped from the input first. ... characters will throw things off. ...
    (alt.php)
  • Re: Expert script (.bat) writers help needed (strip double-quote from string)
    ... Sets or returns the regular expression pattern being searched for. ... Always a RegExp object variable. ... May include any of the regular expression characters defined in the table in the Settings section. ...
    (microsoft.public.windowsxp.help_and_support)
  • Re: RegExp and special caracters
    ... function identifier(str, substr) ... Expression syntax called POSIX 1003.2 Basic Regular Expressions (considered ... where special characters are to be escaped in order not to be considered ... Expressions modelled after the Regular Expression flavor Perl 5 supports ...
    (comp.lang.javascript)
  • Re: RegExp and special caracters
    ... function identifier(str, substr) ... Expression syntax called POSIX 1003.2 Basic Regular Expressions (considered ... where special characters are to be escaped in order not to be considered ... Expressions modelled after the Regular Expression flavor Perl 5 supports ...
    (comp.lang.javascript)

Loading