regx expression? (link included)

W

werwer

A favor please . Would someone tell me if this regx requires
something I don't have installed? I copied it, but it will not
compile. I've never seen a regx written like this and I kind of
wonder if this is input to some other parser. Thanks. (perk 5,8,8)

Here's the link. (I pasted a copy below also, but I'm never sure if
it's readable or not)

http://www.perlmonks.org/?node_id=603809


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;
 
B

Ben Morrow

Quoth werwer said:
A favor please . Would someone tell me if this regx requires
something I don't have installed? I copied it, but it will not
compile. I've never seen a regx written like this and I kind of
wonder if this is input to some other parser. Thanks. (perk 5,8,8)
my $email_address = qr {
(?(DEFINE)
(?<addr_spec> (?&local_part) \@ (?&domain))

Kind-of: this regex is pretty much a demonstration of the new features
in the 5.10 regex engine. So, you would need perl 5.10.0 or later to use
it.

Ben
 
B

Brian McCauley

...this regex is pretty much a demonstration of the new features
in the 5.10 regex engine. So, you would need perl 5.10.0 or later to
use it.

Of course, one of the new features in 5.10 is the pluggable regex
engine, so in principle you _will_ be able to use features from the
5.11/5.12 regexes in 5.10!
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,769
Messages
2,569,578
Members
45,052
Latest member
LucyCarper

Latest Threads

Top