🔥Limited Offer: Get 50% OFFon AI & Full Stack Courses🔥
Back to JavaScript Notes
Topic #89

JS RegExp Quantifiers

RegExp Quantifiers

Regular Expression (Regex) quantifiers define how many times the preceding character, group, or character class must occur in a string. They control the boundaries of your matches, allowing patterns to be flexible.

// Match at least one zero

const pattern = /0+/;

JavaScript RexExp Quantifiers

Revised July 2025

Col 1 Col 2
Code Description
x+ Matches at least one x
x* Matches zero or more occurrences of x
x? Matches zero or one occurrences of x
x{n} Matches n occurences of x
x{n,m} Matches from n to m occurences of x
x{n,} Matches n or more occurences of x

RegExp + Quantifier

x+ matches matches at least one x.

Example

let text = "Hellooo World! Hello W3Schools!";

const pattern = /o+/g;

let result = text.match(pattern);

RegExp * Quantifier

x* matches zero or more occurrences of x.

Example

let text = "Hellooo World! Hello W3Schools!";

const pattern = /lo*/g;

let result = text.match(pattern);

RegExp ? Quantifier

x? matches zero or one occurrences of x.

Example

let text = "1, 100 or 1000?";

const pattern = /10?/g;

let result = text.match(pattern);

RegExp {n} Quantifier

x{n} matches n occurences of x.

let text = "100, 1000 or 10000?";

let pattern = /\d{4}/g;

let result = text.match(pattern);

RegExp {n,m} Quantifier

x{n,m} matches from n to m occurences of x.

let text = "100, 1000 or 10000?";

let pattern = /\d{3,4}/g;

let result = text.match(pattern);

RegExp {n,} Quantifier

x{n,} matches n or more occurences of x.

let text = "100, 1000 or 10000?";

let pattern = /\d{3,}/g;

let result = text.match(pattern);

Regular Expression Methods

Regular Expression Search and Replace can be done with different methods.

These are the most common:

String Methods

Col 1 Col 2
Method Description
match(regex) Returns an Array of results
matchAll(regex) Returns an Iterator of results
replace(regex) Returns a new String
replaceAll(regex) Returns a new String
search(regex) Returns the index of the first match
split(regex) Returns an Array of results

RegExp Methods

Col 1 Col 2
Method Description
regex.exec() Returns an Iterator of results
regex.test() Returns true or false

Note: See Also: JavaScript RegExp Tutorial JavaScript RegExp Flags JavaScript RegExp Character Classes JavaScript RegExp Meta Characters JavaScript RegExp Assertions JavaScript RegExp Groups JavaScript RegExp Patterns JavaScript RegExp Objects JavaScript RegExp Methods

Want to go beyond the notes?

Join CodingNow 2.0's JavaScript course — live mentorship, real projects, and 100% placement support.

Enroll Now — Free Demo Available

JS RegExp Quantifiers – FAQs

Quick answers about learning JS RegExp Quantifiers in JavaScript.

This free note from CodingNow 2.0 explains JS RegExp Quantifiers in JavaScript — concept, syntax and worked code examples you can copy, run and revise before interviews.
Yes. Every JavaScript topic on CodingNow 2.0, including JS RegExp Quantifiers, is 100% free with no signup required.
With focused practice, most students grasp JS RegExp Quantifiers in 1–3 days from these notes; pairing it with CodingNow 2.0's mentor-led course takes you to job-ready depth faster.
Use the code examples in this note, then ask doubts for free on the CodingNow 2.0 Community (/community) — expert instructors answer within 24 hours.
WhatsApp
Call NowEnroll Now