Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl Monk, Perl Meditation

Re^2: Lookahead regex help

by debiandude (Scribe)
on Aug 16, 2004 at 16:34 UTC ( #383360=note: print w/replies, xml ) Need Help??

in reply to Re: Lookahead regex help
in thread Lookahead regex help

That seems to work. Thanks. But I am curious as to what the \2 does?

Replies are listed 'Best First'.
Re^3: Lookahead regex help
by borisz (Canon) on Aug 16, 2004 at 16:37 UTC
    \2 looks for what the second () pair has captured. In this case a single char.
Re^3: Lookahead regex help
by Anonymous Monk on Aug 17, 2004 at 02:25 UTC
    $$ perl -MYAPE::Regex::Explain -e'die YAPE::Regex::Explain->new(qr/((. +)\2*)/i)->explain' The regular expression: (?i-msx:((.)\2*)) matches as follows: NODE EXPLANATION ---------------------------------------------------------------------- (?i-msx: group, but do not capture (case-insensitive) (with ^ and $ matching normally) (with . not matching \n) (matching whitespace and # normally): ---------------------------------------------------------------------- ( group and capture to \1: ---------------------------------------------------------------------- ( group and capture to \2: ---------------------------------------------------------------------- . any character except \n ---------------------------------------------------------------------- ) end of \2 ---------------------------------------------------------------------- \2* what was matched by capture \2 (0 or more times (matching the most amount possible)) ---------------------------------------------------------------------- ) end of \1 ---------------------------------------------------------------------- ) end of grouping ----------------------------------------------------------------------

Log In?

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://383360]
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others drinking their drinks and smoking their pipes about the Monastery: (6)
As of 2021-12-09 12:01 GMT
Find Nodes?
    Voting Booth?
    R or B?

    Results (36 votes). Check out past polls.