Here is the function to tell how many times a search phrase is found in a string.
Note: It's case sensitive.
Thanks Christian White
Note: It's case sensitive.
function howMany(str, term){
return str.match(new RegExp(term, 'g')).length;
};
var text='Visit WHAK.com for WHAKy things!';
var phrase='HAK';
alert(phrase+' is found in\n'+text+'\n'+howMany(text,phrase)+' times.')
Thanks Christian White