Answers for "count characters in a word of a string js"

2

javascript count words in string

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
Posted by: Guest on January-31-2021
12

javascript count character in string

var str = "Hello World!";
var n = str.length;
Posted by: Guest on September-23-2020

Code answers related to "count characters in a word of a string js"

Code answers related to "Javascript"

Browse Popular Code Answers by Language