|
|
|
good chemistry is complicated, and a little bit messy -LW |
|
| PerlMonks |
Being intuitive, conceptually correct, and just doing the right thingby runrig (Abbot) |
| on Jul 29, 2001 at 19:48 UTC ( #100693=note: print w/ replies, xml ) | Need Help?? |
|
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 :)
In Section
Meditations
|
|
||||||||||||||||||||