I want the count of double char occurring in a string, using JS regular expression

For ex:

let a ='caaab'

I need the count of ‘aa’ occurrence, So when I write,

a.match(/aa/g)

it returned with ['aa'] which is wrong,

So any other expression for which I can get ['aa','aa'] ?

123 thoughts on “I want the count of double char occurring in a string, using JS regular expression”

Leave a Comment