in reply to What is greedy and lazy Matching in perl
Hello shankonit,
If you have access to the Camel Book (4th Edition, 2012), you should look at Chapter 5, “Pattern Matching,” especially the section “The Little Engine That /Could(n’t)?/” (pages 241–6). Rule 5 covers the behaviour of quantifiers; the final two paragraphs nicely explain the difference between greedy and non-greedy matching in terms of “backward” vs. “forward” backtracking.
Note for pedants: Messrs Christiansen, d foy, Wall, and Orwant use the term frugal as a synonym for non-greedy. :-)
Hope that helps,
| Athanasius <°(((>< contra mundum | Iustus alius egestas vitae, eros Piratica, |
|
|---|