To see what your regex actually does you can use YAPE::Regex::Explain:
This outputs:use YAPE::Regex::Explain; my $r=YAPE::Regex::Explain->new(qr/^[\w @.]/); print $r->explain();
This might explain why your regex is nog doing what you hoped it would do.The regular expression: (?-imsx:^[\w @.]) matches as follows: NODE EXPLANATION ---------------------------------------------------------------------- (?-imsx: group, but do not capture (case-sensitive) (with ^ and $ matching normally) (with . not matching \n) (matching whitespace and # normally): ---------------------------------------------------------------------- ^ the beginning of the string ---------------------------------------------------------------------- [\w @.] any character of: word characters (a-z, A- Z, 0-9, _), ' ', '@', '.' ---------------------------------------------------------------------- ) end of grouping ----------------------------------------------------------------------
For a better solution look on CPAN, for instance Email::Valid sounds promising
In reply to Re: Simple e-mail validation
by eXile
in thread Simple e-mail validation
by Anonymous Monk
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |