📌  相关文章
📜  javascript 计算字符串中的单词 - Javascript 代码示例

📅  最后修改于: 2022-03-11 15:03:39.657000             🧑  作者: Mango

代码示例1
var str = "your long string with many words.";
var wordCount = str.match(/(\w+)/g).length;
alert(wordCount); //6

//    \w+    between one and unlimited word characters
//    /g     greedy - don't stop after the first match