Greediness

Learn how to apply greedy and nongreedy quantifiers of regex in Perl.

Greedy quantifiers

The + and * quantifiers are greedy: they try to match the input string as much as possible. This can be particularly pernicious. Consider a naïve use of the “zero or more non-newline characters” pattern of .*:

Access this course and 1400+ top-rated courses and projects.