Perl Pattern-Matching Quantifiers

By Paul Hoffman

Part of Perl For Dummies Cheat Sheet

Perl enables you to use common symbols to instruct the program you’re writing to match data once, never, or up to a certain number of times. The following table shows you which symbol to use to get the match you want:

Symbol Meaning
+ Match 1 or more times
* Match 0 or more times
? Match 0 or 1 time
{n} Match exactly n times
{n,} Match at least n times
{n,m} Match at least n, but not more than m, times (these values must
be less than 65,536)