Perl Pattern-Matching Quantifiers

Part of the 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)
  • Add a Comment
  • Print
  • Share
blog comments powered by Disqus

SERIES
Perl For Dummies Cheat Sheet

Advertisement

Inside Dummies.com