Skip to content

Instantly share code, notes, and snippets.

View ariews's full-sized avatar

Arie W. Subagja ariews

View GitHub Profile
/**
* Takes the given HTML data, replaces all its HTML tags with nothing, splits the result by spaces,
* and outputs the array length i.e. number of words.
*
* @param string htmlData HTML Data
* @return int Word Count
*/
function GetWordCount(htmlData) {
return htmlData.replace(/<(?:.|\s)*?>/g, '').split(' ').length;
}