Beefy Boxes and Bandwidth Generously Provided by pair Networks
Do you know where your variables are?
 
PerlMonks  

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

by runrig (Abbot)
on Jul 29, 2001 at 19:48 UTC ( #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 :)


Comment on Being intuitive, conceptually correct, and just doing the right thing
Select or Download Code

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others surveying the Monastery: (4)
As of 2014-09-16 01:21 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    My favorite cookbook is:










    Results (155 votes), past polls