How i change the regular Expression for count the word which anyone enter the write something on that
(countWords=()=>{
s = document.getElementById("inputString").value;
s = s.replace(/(^\s*)|(\s*$)/gi,"");
s = s.replace(/[ ]{2,4}/gi," ");
s = s.replace(/\n /,"\n");
document.getElementById("wordcount").value = s.split(' ').length;
})()
<textarea name="inputString" id="inputString" cols="50" rows="4">Text to count</textarea>
<br>
<input type="button" name="Convert" value="Count Words" onClick="countWords();">
<input name="wordcount" id="wordcount" type="text" value="" size="6">
Aucun commentaire:
Enregistrer un commentaire