Safari Books Online is a digital library providing on-demand subscription access to thousands of learning resources.
Greed isn’t about money, at least where regular expressions are concerned. It’s the term used to describe the matching behavior of most regular-expression engines, Perl’s included.
A general rule is that a Perl regular expression will return the “leftmost longest” match it can find, at the first position in a string where it can find a match of any length. Repetition operators like * and + “gobble up” characters in the string until matching more characters causes the match to fail: