Beefy Boxes and Bandwidth Generously Provided by pair Networks
Your skill will accomplish
what the force of many cannot
 
PerlMonks  

comment on

( [id://3333]=superdoc: print w/replies, xml ) Need Help??

The main question is whether \2 should have a value at all when that alternate failed to match last time through the alternation.

See the recent bug report Perl #21563. There is definite inconsistency in how backreferences are preserved or discarded when backtracking, but it is unclear what consistent behaviour we should be aiming at.

Based on the expectation I (hvds) described in that issue ("... that we would retain only results from the last successful match, so that ((a)|(b))+ would never return captures of both a and b") with which demerphq agreed, neither of your strings should match - after we match the /a*b?d/ alternate, \2 from the other alternate should be unset.

I hope that at some point we will settle on the principle of how it should behave, and document that clearly; I don't think we're there yet. I would not, however, expect to see extensive comparisons with other regexp engines in Perl's documentation: there are too many moving targets involved. I think I remember that PCRE documentation had more of such comparisons though.


In reply to Re: Precise backreference semantics in Perl regular expressions by hv
in thread Precise backreference semantics in Perl regular expressions by Gro-Tsen

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post; it's "PerlMonks-approved HTML":



  • Are you posting in the right place? Check out Where do I post X? to know for sure.
  • Posts may use any of the Perl Monks Approved HTML tags. Currently these include the following:
    <code> <a> <b> <big> <blockquote> <br /> <dd> <dl> <dt> <em> <font> <h1> <h2> <h3> <h4> <h5> <h6> <hr /> <i> <li> <nbsp> <ol> <p> <small> <strike> <strong> <sub> <sup> <table> <td> <th> <tr> <tt> <u> <ul>
  • Snippets of code should be wrapped in <code> tags not <pre> tags. In fact, <pre> tags should generally be avoided. If they must be used, extreme care should be taken to ensure that their contents do not have long lines (<70 chars), in order to prevent horizontal scrolling (and possible janitor intervention).
  • Want more info? How to link or How to display code and escape characters are good places to start.
Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others taking refuge in the Monastery: (6)
As of 2024-05-21 16:29 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found