Beefy Boxes and Bandwidth Generously Provided by pair Networks
No such thing as a small change
 
PerlMonks  

Being intuitive, conceptually correct, and just doing the right thing

by runrig (Abbot)
on Jul 29, 2001 at 19:48 UTC ( [id://100693]=note: print w/replies, xml ) Need Help??


in reply to Being pretentious, and getting away with it.

How long has it been that regexes have returned anything predictable from non-matching parenthesis within regexes that match?

With a regex like /A(.)?B/, perl used to fill $1 with whatever the last attempt at a match was, and so the result was not undefined, but unpredictable. So on a string like 'AB', you'd end up with 'B' in $1, and although it might be non-intuitive, it was actually conceptually correct, because the string does match /A(B)?B/, and it was up to the programmer to use something more sensible, like </code>/A((.)?)B/</code>, and only depend on the inner parenthesis if the outer ones contain something besides the empty string.

But now I guess perl just does (or will do) the right thing :)

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others scrutinizing the Monastery: (4)
As of 2024-04-25 12:11 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found