Home Articles FAQs XREF Games Software Instant Books BBS About FOLDOC RFCs Feedback Sitemap
irt.Org
#

Q1619 How do I get a word count of a string?

You are here: irt.org | FAQ | JavaScript | Text | Q1619 [ previous next ]

Larry Seltzer writes:

<script language="JavaScript"><!--
function wordcount(string) {
  var a = string.split(/\s+/g); // split the sentence into an array of words
  return a.length;
}
//--></script>

©2018 Martin Webb