O'Reilly logo

JavaScript Regular Expressions by Gabriel Manricks, Loiane Groner

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Quantifiers

In the following table, you can find the patterns for quantifiers, which specify how many instances of a character, group, or character class must be present in an input for a match to be found.

Pattern

Description

Example

{n}

This matches exactly n occurrences of a regular expression.

/\d{5}/ matches "12345" (five digits) in "1234567890".

{n,}

This matches n or more occurrences of a regular expression.

/\d{5,}/ matches "1234567890" (minimum of five digits) in "1234567890".

{n,m}

This matches n to m number of occurrences of a regular expression.

/\d{5,7}/ matches "1234567" (minimum of five digits and a maximum of seven digits) in "1234567890".

*

This matches zero or more occurrences and is equivalent to {0,} ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required