It’s quite simple. Whatever expression you would like to count put it in a simple regex like /red/g
var es = "There is a woman in red who listens to simply red and her name is Mildred"
redCount = es.match(/red/g).length; // <- 3
It’s quite simple. Whatever expression you would like to count put it in a simple regex like /red/g
var es = "There is a woman in red who listens to simply red and her name is Mildred"
redCount = es.match(/red/g).length; // <- 3