A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://www.geeksforgeeks.org/javascript/javascript-regexp-x-quantifier/ below:

JavaScript RegExp {X,} Quantifier - GeeksforGeeks

JavaScript RegExp {X,} Quantifier

Last Updated : 11 Jul, 2025

The RegExp m{X, } Quantifier in JavaScript is used to find the match of any string that contains a sequence of m, at least X times, where X is a number.

JavaScript
let str = "GeeksforGeeeks e@_123_$";
let regex = /k{1,}/gi;
let match = str.match(regex);

console.log("Found " + match.length
    + " matches: " + match);

Output
Found 2 matches: k,k
Syntax: 
/m{X, }/ 

Example 1: Matches the presence of the character 'e' at least 1 times in the whole string. 

JavaScript
let str = "GeeksforGeeeks e@_123_$";
let regex = /e{1,}/gi;
let match = str.match(regex);

console.log("Found " + match.length
    + " matches: " + match);

Output
Found 3 matches: ee,eee,e

Example 2: Replaces the word containing at least 2 'e' with '$' character. 

JavaScript
let str = "ee@128GeeeeK";
let regex = new RegExp("e{2,}", "gi");
let replace = "$";
let match = str.replace(regex, replace);
console.log(" New string: " + match);

Output
 New string: $@128G$K
Recommended Links:

RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4