StringTools - Maple Help

Home : Support : Online Help : Programming : Names and Strings : StringTools Package : WhiteSpace Utilities : StringTools/Trim

StringTools

 TrimLeft
 trim leading whitespace from a string
 TrimRight
 trim trailing whitespace from a string
 Trim
 trim leading and trailing whitespace from a string

 Calling Sequence TrimLeft( s ) TrimRight( s ) Trim( s )

Parameters

 s - Maple string

Description

 • The TrimLeft(s) command removes the leading whitespace from string s and returns the resulting terminal substring. If string s has no leading whitespace, then it is returned unchanged.
 • The TrimRight(s) command removes the trailing whitespace from string s and returns the resulting substring.  If string s has no trailing whitespace, then it is returned unchanged.
 The TrimRight function is defined by $\mathrm{TrimRight}\left(s\right)=\mathrm{Reverse}\left(\mathrm{TrimLeft}\left(\mathrm{Reverse}\left(s\right)\right)\right)$.
 • The Trim(s) command is defined to be the composition $\mathrm{TrimRight}@\mathrm{TrimLeft}$.

Examples

 > $\mathrm{with}\left(\mathrm{StringTools}\right):$
 > $s≔"This is a test."$
 ${s}{:=}{"This is a test."}$ (1)
 > $\mathrm{TrimLeft}\left(s\right)$
 ${"This is a test."}$ (2)
 > $\mathrm{TrimRight}\left(s\right)$
 ${"This is a test."}$ (3)
 > $\mathrm{Trim}\left(s\right)$
 ${"This is a test."}$ (4)