Beefy Boxes and Bandwidth Generously Provided by pair Networks
XP is just a number
 
PerlMonks  

Re^3: Regular Expressions

by maard (Pilgrim)
on May 18, 2005 at 08:31 UTC ( [id://458113]=note: print w/replies, xml ) Need Help??


in reply to Re^2: Regular Expressions
in thread Regular Expressions

perl -e '$_="aaaa"; print "Match: $1\n" if /(?:(a)\1)/;'

prints 'Match: a'
because you asked perl to grab letter 'a' and then another 'a' after this.

perl -e '$_="aaaa"; print "Match: $1\n" if /((?:a)\1)/;'
prints nothing because at the point of \1 there must be already captured group, which isn't a case, because \1 is prefixed by non-capturing parens.

As for absence of warning in ((?:a)\1) - maybe regexp engine only issues warning at compile time if there're no grouping parens in re at all. (maybe it just doesn't perform complicated compile-time checking of regexp to see if grouping parens really come before \1).

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others lurking in the Monastery: (3)
As of 2024-04-20 05:08 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found