in reply to Re: stripping out email address from string
in thread stripping out email address from string
Also note that leading and trailing .* on a regex is just meaningless noise, as the regex will match anywhere in the string by default.
If I were to do this with just a plain regex, I'd go with
or, a little shorter (but less clear to the uninitiated),$__emailAddressIs =~ /<([^<@>]+@[^<@>]+)>/; $_sendTo = $1;
This will only match a sequence of <, followed by @, followed by >, with each symbol separated from the next by one or more characters other than those three symbols. It's still not perfect (using regexes to determine the validity of an email address is a fool's game), but should be close enough for most purposes.($_sendTo) = $__emailAddressIs =~ /<([^<@>]+@[^<@>]+)>/;
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^3: stripping out email address from string
by JavaFan (Canon) on Aug 23, 2009 at 16:39 UTC |