JavaScript RegExp + Quantifier (original) (raw)

Last Updated : 10 Dec, 2024

The **m+ Quantifier in JavaScript is used to find the match of any string that contains at least one m.

JavaScript `

let str = "GeeksforGeeks@123$"; let regex = /G+/gi; let match = str.match(regex);

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

`

**Syntax:

/m+/

**Example 1: Matches the presence of the word 'e' in the whole string.

JavaScript `

let str = "GeeksforGeeks@123$"; let regex = /e+/gi; let match = str.match(regex);

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

`

Output

Found 2 matches: ee,ee

**Example 2: Replaces the word 'ee' with 'EE'.

JavaScript `

let str = "GeeKY@128"; let regex = new RegExp("e+", "gi"); let replace = "EE"; let match = str.replace(regex, replace); console.log(" New string: " + match);

`

Output

New string: GEEKY@128