Skip to main content

Quantifiers

Quantifiers define how many times a character, metacharacter, or character set can be repeated.

SymbolNameMeaning
?Question Mark0 or 1 repetition
*AsteriskZero or more times
+Plus signOne or more times
{n,m}Curly bracesBetween n and m times

Examples:

  • /hello*/ matches "hell", "hello", "helloo", "hellooo", etc.
  • /hello+/ matches "hello", "helloo", "hellooo", etc. (but not "hell")
  • /hello?/ matches only "hell" or "hello"
  • /hello{2,5}/ matches "helloo", "hellooo", "helloooo", "hellooooo"