On Fri, Jan 31, 2003 at 05:08:57PM +0000, Earle Martin wrote: > On Fri, Jan 31, 2003 at 07:08:19AM +0000, Dave Cross wrote: > > It's Jeffery Friedl's regex for checking a valid email address. > Oh. Naughty person; he gave me the impression that he'd written it > himself!
It also includes all sorts of things that are now deprecated. An (untested) decompiled version of it is: | my $WS=qr/[\040\t]*/; | my $CTEXT=qr/[^\\\x80-\xff\n\015()]/; | my $QP=qr/\\[^\x80-\xff]/; # I don't agree with this, it shouldn't | # include newlines and \r's | my $CC1=qr/$CTEXT*(?:$QP$CTEXT*)*/; # lowest level of comment content | my $COMMENT1=qr/\($CC1\)/; | # this is where we only do one level | # deep of commenting, and why my post | # earlier breaks this. | my $CC2=qr/$CTEXT*(?:(?:$QP|$COMMENT1)$CTEXT*)*/; | my $COMMENT2=qr/\($CC2\)/; | my $CFWS=qr/$WS(?:$COMMENT2$WS)*/; # comment folding whitespace | my $QTEXT=qr/[^\\\x80-\xff\n\015"]/; | my $QSTRING=qr/"$QTEXT*(?:$QP$QTEXT*)*"/; # quoted string | my $DTEXT=qr/[^\\\x80-\xff\n\015\[\]]/; | my $ATEXT=qr/[^(\040)<>@,;:".\\\[\]\000-\037\x80-\xff]/; | my $ATOM=qr/$ATEXT+(?!$ATEXT)/; | | my $RE=qr/ | $CFWS | (?: | # bare email address | (?: $ATOM | $QSTRING ) $CFWS | (?: \. $CFWS (?: $ATOM | $QSTRING ) $CFWS )* | @ | $CFWS (?: $ATOM | \[(?:$DTEXT|$QP)*\] ) $CFWS | (?: \. $CFWS (?: $ATOM | \[(?:$DTEXT|$QP)*\] ) $CFWS )* | | | # phrase and addr-spec | (?: $ATOM | $QSTRING ) | # this next line is actually just (?:$WS|$ATEXT)* | [^()<>@,;:".\\\[\]\x80-\xff\000-\010\012-\037]* | (?: | (?: $COMMENT2 | $QSTRING ) | [^()<>@,;:".\\\[\]\x80-\xff\000-\010\012-\037]* | )* | < | $CFWS | (?: @ # Source routed addresses | $CFWS (?: $ATOM | \[(?:$DTEXT|$QP)*\] ) $CFWS | (?: \. $CFWS (?: $ATOM | \[(?:$DTEXT|$QP)*\] ) $CFWS )* | (?: , $CFWS @ $CFWS | (?: $ATOM | \[(?:$DTEXT|$QP)*\] ) $CFWS | (?: \. $CFWS (?: $ATOM | \[(?:$DTEXT|$QP)*\] ) $CFWS )* | )* | : $CFWS | )? | (?: $ATOM | $QSTRING ) $CFWS | (?: \. $CFWS (?: $ATOM | $QSTRING ) $CFWS )* | @ | $CFWS (?: $ATOM | \[(?:$DTEXT|$QP)*\] ) $CFWS | (?: \. $CFWS (?: $ATOM | \[(?:$DTEXT|$QP)*\] ) $CFWS )* | > | ) | /x; -- Lusercop.net - LARTing Lusers everywhere since 2002