in reply to regexp to only allow for formally valid email addresses

You need to escape the dots in your regex.

Update: Nevermind this post. I stand corrected and learned Yet Another Perl Nuance. Thanks Thelonius & Fletch.

  • Comment on Re: regexp to only allow for formally valid email addresses

Replies are listed 'Best First'.
Re^2: regexp to only allow for formally valid email addresses
by Fletch (Bishop) on Mar 07, 2007 at 19:30 UTC
    $ perl -le '$_ = "oh really?"; print unless /[.]/;' oh really?

      Unless you don't think the character classes are a bit redundant. I assume fraktalisman only wants to match \w as well as '-' and '.' since its for e-mail addresses.

      # my guess is that he's not trying to do this =~ /^[.]+@[.]+$/ # either of these make more sense for matching an e-mail address =~ /^[a-zA-Z_\-\.0-9]+@[a-zA-Z_\-\.0-9]+$/ =~ /^[\w\-\.]+@[\w\-\.]+$/

      Or am I missing something painfully obvious?

        The dot is not special within square brackets. /[.]/ only matches ".", not "a".