split a string into words
count the number of words in a string
Words( s )
WordCount( s )
The Words(s) command splits a string into its constituent words. A list of the words in the input string s, in order, is returned. The non-word characters in the string are elided from the output.
The WordCount(s) command counts the number of words in a given string s.
A word is defined to be a maximal contiguous sequence of alphanumeric characters or the apostrophe character ('). Words are delimited by non-word characters.
All of the StringTools package commands treat strings as (null-terminated) sequences of 8-bit (ASCII) characters. Thus, there is no support for multibyte character encodings, such as unicode encodings.
Words⁡This is a
WordCount⁡This is a
Words⁡The Word command correctly parses a word with an apostrophe, like isn't, as a single word.
WordCount⁡The WordCount command correctly counts a word with an apostrophe, like isn't, as a single word.
Words⁡The Words command ignores punctuation, like colons (:); this is very useful!
WordCount⁡The WordCount command also ignores punctuation, like colons (:); this is very useful!
Download Help Document