I am creating a class to detect emoticons and have the following to detect :) smilies including their various variations (=], =), [=, [:, etc.), but it doesn't work and I can't for the life of me figure out what is wrong. I'm testing it in JSFiddle.
var DetectEmoticons = {
countHappy: function(data) {
var pattern = new RegExp("[:/=]-?[]/)] | [[/(]-?[:/=]", "g");
var count = (data.match(pattern) || []).length;
return count;
}
}
alert(DetectEmoticons.countHappy("=)"));