StringTools - Maple Programming Help

Online Help

All Products    Maple    MapleSim


Home : Support : Online Help : Programming : Names and Strings : StringTools Package : English Text : StringTools/Words

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.

Examples

withStringTools:

WordsThis is a sentence.

This,is,a,sentence

(1)

WordCountThis is a sentence.

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]