WordCount - Maple Help
For the best experience, we recommend viewing online help using Google Chrome or Microsoft Edge.

Online Help

All Products    Maple    MapleSim


StringTools

  

Words

  

split a string into words

  

WordCount

  

count the number of words in a string

 

Calling Sequence

Parameters

Description

Examples

Calling Sequence

Words( s )

WordCount( s )

Parameters

s

-

Maple string

Description

• 

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.

Examples

withStringTools:

WordsThis is a\nsentence.

This,is,a,sentence

(1)

WordCountThis is a\nsentence.

4

(2)

WordsThe 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

(3)

WordCountThe WordCount command correctly counts a word with an apostrophe, like isn't, as a single word.

16

(4)

WordsThe Words command ignores punctuation, like colons (:); this is very useful!

The,Words,command,ignores,punctuation,like,colons,this,is,very,useful

(5)

WordCountThe WordCount command also ignores punctuation, like colons (:); this is very useful!

12

(6)

See Also

string

StringTools

StringTools[Split]