I don't think the idea of handling form text value
differently
if it looks like an email addess is particularly wise,
but if the OP is determined
to go with such an approach, then my regex above is as good
a heurstic as anything else. Sure, you could use a CPAN
module that can correctly parse RFC822 addresses, but
since we are dealing with a web form where users have
typed in stuff by hand, its fairly unlikely they're typing
the full RFCish stuff involving quoting, <> etc. | [reply] |
"Randal L. Schwartz"@vms-relay.stonehenge.comm
And if that was my legitmate email address because of the way my
internal company mailing system was set up, you've now given me
no opportunity to use your web site. You made two common mistakes
in your regex:
- \w doesn't match hyphen, and yet hyphen can easily appear in
a domain name.
- Legitimate email addresses might have embedded spaces.
The proper answer here is to not make things up and use the
FAQ answers. Don't just invent your own thing.
| [reply] [d/l] |
I also notified the guys at <foo@example.com>
| [reply] [d/l] |
Yes, Merlyn. but i can't restrict myself to a any perl module b/c i know this reqular expression will be ported to java later on. | [reply] |
If you can't use the Perl modules directly, then lift the regex from the modules. However, it's quite long, and it's quite long for a reason. Be sure you read my other posts in this thread to avoid disinformation and misinformed people who think they are helping.
| [reply] |