StringTools - Maple Programming Help

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

StringTools

 WordStart
 locate the beginning of a word
 WordEnd
 locate the end of a word
 WordContaining
 return the word containing a given index

 Calling Sequence WordStart( s, index ) WordEnd( s, index ) WordContaining( s, index )

Parameters

 s - Maple string index - integer; a valid index into the string s

Description

 • The WordStart command returns the index of the beginning (first letter) of the word containing the index index, if any. If the second argument index does not occur in a word in the string s, then the value $0$ is returned.
 • The WordEnd command returns the index of the end (last letter) of the word containing the index index, if any. If the second argument index does not occur in a word in the string s, then the value $0$ is returned.
 • The WordContaining command returns the word containing the index index, if index lies within a word in the string s, or the empty string $""$, otherwise.
 • For all three commands, the second argument index must be a valid index into the string presented as the first argument.
 • If the index index lies within a word in the string s, then WordContaining( s, index ) = s[ WordStart( s, index ) .. WordEnd( s, index ) ].
 • 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

 > $\mathrm{with}\left(\mathrm{StringTools}\right):$
 > $\mathrm{WordStart}\left("Voi che sapete, che cosa e amor, donne, vedete, s\text{'}io l\text{'}ho nel cor.",7\right)$
 ${5}$ (1)
 > $\mathrm{WordEnd}\left("Voi che sapete, che cosa e amor, donne, vedete, s\text{'}io l\text{'}ho nel cor.",7\right)$
 ${7}$ (2)
 > $\mathrm{WordContaining}\left("Voi che sapete, che cosa e amor, donne, vedete, s\text{'}io l\text{'}ho nel cor.",7\right)$
 ${"che"}$ (3)