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

I agree with the suggestions to use a ready-made regexp. But if for some reason I had to reinvent one, I'd extend the \w token as much as necessary rather than go from scratch, something like...
$spammer = length($f{'Email'}) && $f{'Email'} !~ /^(^\w|\-|\.)+\@(\w|\-|\.)+$/;

-M

Free your mind

Replies are listed 'Best First'.
Re^2: regexp to only allow for formally valid email addresses
by fraktalisman (Hermit) on Mar 08, 2007 at 11:33 UTC

    Word characters (\w) might include local characters like German Ä ö ü ß on a German webserver. Although these Umlaut characters should be, in theory, valid in email adresses (in my interpretation of RFC 822), I know from experience that their occurence in email addresses usually causes problems sooner or later. At least one German provider (T-Online) used to allow for those chars, but I would rather disallow and have the user enter an email address which is safe for international use.