JSFiddle - React, Tailwind, and code Playground
by Miklos Nagy
JavaScript
function wordCount( val ){
var wom = val.match(/\S+/g); //replace or what
return{
charactersNoSpaces : val.replace(/\s+/g).length,
characters : val.length,
words : wom ? wom.length : 0,
lines : val.split(/\r*\n/).length
};
}
console.log(wordCount(`HELLO HELLO <br/> HELLO \`));