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, X times where X is a number.
JavaScript
let str = "Geekkkksss@_123_$";
let regex = /k{2}/gi;
let match = str.match(regex);
console.log(match);
Syntax:
/m{X}/Syntax with modifiers:
// or
new RegExp("m{X}")
/\m{X}/g
// or
new RegExp("m{X}", "g")
Example 1: Matches the presence of the word 'ee' in the whole string.
JavaScript
let str = "GeeksforGeeks@_123_$";
let regex = /e{2}/gi;
let match = str.match(regex);
console.log("Found " + match.length + " matches: " + match);
Found 2 matches: ee,ee
Example 2: Replaces the word 'ee' with the character 'E'.
JavaScript
let str = "ee@128GeeeeK";
let regex = new RegExp("e{2}", "gi");
let replace = "E";
let match = str.replace(regex, replace);
console.log(" New string: " + match);
New string: E@128GEEKRecommended 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