Re: What this means "(\w|-)+@\w"? [message #174788 is a reply to message #174786] |
Thu, 07 July 2011 19:12 |
Thomas 'PointedEars'
Messages: 701 Registered: October 2010
Karma:
|
Senior Member |
|
|
Eli the Bearded wrote:
> In comp.lang.php, zhang yun <bigzhangyun(at)gmail(dot)com> wrote:
>> $reg ='/^[0-9a-zA-z](\w|-)+@\w+\.('.$str.')$/';
>
> This bit makes a larger "perl compatable" regular expression ("pcre").
_P_erl_-_compat_i_ble (_PCRE_). (You nitpick, I nitpick ;-))
> ^ anchor to start of string
> [0-9a-zA-z] broken attempt to match a number or letter
> will also match [ ] \ ^ _ `
Now come on, that is probably just a typo. Make the last `z' a `Z'
(uppercase) and it will not match those extra characters (it will
match too few addresses, though).
> Elijah
> ------
> uses this email address precisely because it gets rejected by bad
> verifiers
ACK. Good to see it passed mine (and was subsequently SMTP-checked as being
OK) :)
atext="[A-Za-z0-9!#\$%&'*+/=?^_\`{|}~-]"
dot_atom_text="$atext+(\\.$atext+)*"
dot_atom=$dot_atom_text
if [ -z "`echo "$i" | egrep -e "${dot_atom}@${dot_atom}"`" ]; then
# not syntactically valid
fi
It is a shell script, but you can probably see how it works. It is derived
directly from RFC 2822, section 3.4.1, which was current at the time it was
written. Do I need to update it to RFC 5322 in any way?
PointedEars
--
Anyone who slaps a 'this page is best viewed with Browser X' label on
a Web page appears to be yearning for the bad old days, before the Web,
when you had very little chance of reading a document written on another
computer, another word processor, or another network. -- Tim Berners-Lee
|
|
|