Regular Expression for accurate word-count using JavaScript

后端 未结 7 1006
陌清茗
陌清茗 2020-12-01 07:15

I\'m trying to put together a regular expression for a JavaScript command that accurately counts the number of words in a textarea.

One solution I had found is as fo

相关标签:
7条回答
  • 2020-12-01 07:41

    my simple JavaScript library, called FuncJS has a function called "count()" which does exactly what it's called — count words.

    For example, say that you have a string full of words, you can simply place it in between the function brackets, like this:

    count("How many words are in this string?");
    

    and then call the function, which will then return the number of words. Also, this function is designed to ignore any amount of whitespace, thus giving an accurate result.

    To learn more about this function, please read the documentation at http://docs.funcjs.webege.com/count().html and the download link for FuncJS is also on the page.

    Hope this helps anyone wanting to do this! :)

    0 讨论(0)
提交回复
热议问题