I need to count occurrences of an array in a string. I have problems with the special characters like ;/()
var msg = "hello world :)";
var tce = [":)", ":(", ":/" ];
var countOcurrences = 0;
for (var i = 0; i < tce.length; i++) {
res = msg.match(/tce[i]/g);
if (res != null) countOcurrences += res.length;
}
I think with regular expression, it may become more easy.