[Madrid-pm] Regex Email By Abigail

lasi lasi en freekeylabs.com
Dom Mar 4 23:45:12 PST 2007


Se acabo esa duda existencial de: "Me hago una gramatica o con una regex 
voy que me mato".

La "regex" tiene un sospechoso parecido con 
http://es.wikipedia.org/wiki/Backus-Naur_form

Asi va a acabar apeteciendo aprender perl y todo ;-)

Diego Kuperman wrote:
> Esto lo he visto en la lista de barcelona-pm y me parecio que os podria 
> interesar. Imagino que esto ya estara en Regexp::Common :)
>
> ----
> Newsgroups: comp.lang.perl.misc
> From: Abigail <abigail en abigail.be>
> Subject: Regexp for email addresses.
> Reply-To: abigail en abigail.be
> X-Date: MMMMCMXV September MCMXCIII
> Organization: Abigail's Kinderboerderijen
> X-HTTP: http://www.abigail.be/
> X-Revision: $Revision: 1.2 $
> Message-Id: <slrnet71ah.2rh.abigail en alexandra.abigail.be>
> User-Agent: slrn/0.9.7.4 (Linux)
> Date: 14 Feb 2007 21:55:40 GMT
> Lines: 57
>
>
> use 5.9.5;   # In fact, you need the newest blead.
>
>
> my $email_address = qr {
>      (?(DEFINE)
>        (?<addr_spec>       (?&local_part) \@ (?&domain))
>        (?<local_part>      (?&dot_atom) | (?&quoted_string))
>        (?<domain>          (?&dot_atom) | (?&domain_literal))
>        (?<domain_literal>  (?&CFWS)? \[ (?: (?&FWS)? (?&dcontent))* (?&FWS)?
>                                      \] (?&CFWS)?)
>        (?<dcontent>        (?&dtext) | (?&quoted_pair))
>        (?<dtext>           (?&NO_WS_CTL) | [\x21-\x5a\x5e-\x7e])
>
>        (?<atext>           (?&ALPHA) | (?&DIGIT) | [!#\$%&'*+-/=?^_`{|}~])
>        (?<atom>            (?&CFWS)? (?&atext)+ (?&CFWS)?)
>        (?<dot_atom>        (?&CFWS)? (?&dot_atom_text) (?&CFWS)?)
>        (?<dot_atom_text>   (?&atext)+ (?: \. (?&atext)+)*)
>
>        (?<text>            [\x01-\x09\x0b\x0c\x0e-\x7f])
>        (?<quoted_pair>     \\ (?&text))
>
>        (?<qtext>           (?&NO_WS_CTL) | [\x21\x23-\x5b\x5d-\x7e])
>        (?<qcontent>        (?&qtext) | (?&quoted_pair))
>        (?<quoted_string>   (?&CFWS)? (?&DQUOTE) (?:(?&FWS)? (?&qcontent))*
>                             (?&FWS)? (?&DQUOTE) (?&CFWS)?)
>
>        (?<word>            (?&atom) | (?&quoted_string))
>        (?<phrase>          (?&word)+)
>
>        # Folding white space
>        (?<FWS>             (?: (?&WSP)* (?&CRLF))? (?&WSP)+)
>        (?<ctext>           (?&NO_WS_CTL) | [\x21-\x27\x2a-\x5b\x5d-\x7e])
>        (?<ccontent>        (?&ctext) | (?&quoted_pair) | (?&comment))
>        (?<comment>         \( (?: (?&FWS)? (?&ccontent))* (?&FWS)? \) )
>        (?<CFWS>            (?: (?&FWS)? (?&comment))*
>                            (?: (?:(?&FWS)? (?&comment)) | (?&FWS)))
>
>        # No whitespace control
>        (?<NO_WS_CTL>       [\x01-\x08\x0b\x0c\x0e-\x1f\x7f])
>
>        (?<ALPHA>           [A-Za-z])
>        (?<DIGIT>           [0-9])
>        (?<CRLF>            \x0d \x0a)
>        (?<DQUOTE>          ")
>        (?<WSP>             [\x20\x09])
>      )
>
>      (?&addr_spec)
> }x;
>
>
>
>
> Abigail
>   



Más información sobre la lista de distribución Madrid-pm