- publishing free software manuals
Perl Language Reference Manual
by Larry Wall and others
Paperback (6"x9"), 724 pages
ISBN 9781906966027
RRP £29.95 ($39.95)

Sales of this book support The Perl Foundation! Get a printed copy>>>

14.6 QUANTIFIERS

Quantifiers are greedy by default and match the longest leftmost.

Maximal Minimal Possessive Allowed range
{n,m} {n,m}? {n,m}+ Must occur at least n times but no more than m times
{n,} {n,}? {n,}+ Must occur at least n times
{n} {n}? {n}+ Must occur exactly n times
* *? *+ 0 or more times (same as {0,})
+ +? ++ 1 or more times (same as {1,})
? ?? ?+ 0 or 1 time (same as {0,1})
The possessive forms (new in Perl 5.10) prevent backtracking: what gets matched by a pattern with a possessive quantifier will not be backtracked into, even if that causes the whole match to fail. There is no quantifier {,n}. That's interpreted as a literal string.
ISBN 9781906966027Perl Language Reference ManualSee the print edition