Beefy Boxes and Bandwidth Generously Provided by pair Networks
P is for Practical
 
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 chilling in the Monastery: (12)
As of 2014-10-02 13:54 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    What is your favourite meta-syntactic variable name?














    Results (61 votes), past polls