On Thu, 13 Jun 2002 21:36:25 -0700, Paul Makepeace wrote: >Can someone explain the first result? > >$ perl -wle '$_ = "small - medium - large"; > /- (.+?)$/; print $1;
>medium - large >I was expecting just "large" with the non-greedy match. Basic rule: non-greediness only affects the right hand side of a match. Put in a more technical way: the regex scans the string fro a match from left to right, trying each character in turn as a first character for a match. It stops when it finds one. The "non-greedy" rule only applies to what it matches, in case of multiple candidates, with this starting point. Or, with another slogan: the leftmost match wins. -- Bart.