Beefy Boxes and Bandwidth Generously Provided by pair Networks
Clear questions and runnable code
get the best and fastest answer
 
PerlMonks  

Re: Regexp not capturing in named subrules (leftmost)

by tye (Sage)
on Sep 16, 2009 at 02:50 UTC ( [id://795510]=note: print w/replies, xml ) Need Help??


in reply to Regexp not capturing in named subrules

perlre says:

If multiple distinct capture buffers have the same name then the $+{NAME} will refer to the leftmost defined buffer in the match.

- tye        

  • Comment on Re: Regexp not capturing in named subrules (leftmost)

Replies are listed 'Best First'.
Re^2: Regexp not capturing in named subrules (leftmost)
by diotalevi (Canon) on Sep 16, 2009 at 03:01 UTC

    However, what puzzles me and should be apparent is that nothing at all was captured.

    ⠤⠤ ⠙⠊⠕⠞⠁⠇⠑⠧⠊

      Since the "leftmost defined buffer" is inside of a group quantified by {0}, it isn't puzzling to me that this buffer didn't match. And it isn't surprising that a buffer that didn't match doesn't capture anything.

      Perhaps you were now expecting thing => undef, contrary to your previously stated expectation? If so, my limited testing shows that %+ keys aren't pre-populated but the values are returned by magic (%+ always appears empty even when $+{moo} returns "o" after 'cow' =~ /(?<moo>o+)/).

      Update: I'm glad to report that the lack of keys in %+ appears to have only been an effect of the quick-hack method I used to test, related to evaluation order problems.

      - tye        

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others imbibing at the Monastery: (2)
As of 2024-04-25 07:30 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found