Skip to main content
deckarduk
Inspiring
March 29, 2023
Question

Word count question...

  • March 29, 2023
  • 0 replies
  • 311 views

Hi there,

Just a quick check if the method below is suitable for getting a more accurate word count on a page?

I do have another method however, I thought I'd try a version with a RegExp.

Thanks in advance.

var theCount = 0;
var myRegExp = /\w+/;
var numOfWords = this.getPageNumWords(0);
for (var y = 0; y < numOfWords; y++) {
    if(myRegExp.test(this.getPageNthWord(0,y))) {
        theCount = theCount + 1;
    }
}
theCount;

 

This topic has been closed for replies.