StringTools
Words
split a string into words
WordCount
count the number of words in a string
Calling Sequence
Parameters
Description
Examples
Words( s )
WordCount( s )
s
-
Maple string
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.
with⁡StringTools:
Words⁡This is a\nsentence.
This,is,a,sentence
WordCount⁡This is a\nsentence.
4
Words⁡The Word command correctly parses a word with an apostrophe, like isn't, as a single word.
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.
16
Words⁡The Words command ignores punctuation, like colons (:); this is very useful!
The,Words,command,ignores,punctuation,like,colons,this,is,very,useful
WordCount⁡The WordCount command also ignores punctuation, like colons (:); this is very useful!
12
See Also
string
StringTools[Split]
Download Help Document