Substitute - Maple Help

StringTools

 Substitute
 search for and replace the first occurrence of a string by another string
 SubstituteAll
 search for and replace all occurrences of a string by another string

 Calling Sequence Substitute( s, from, to ) SubstituteAll( s, from, to )

Parameters

 s - string from - string to - string

Description

 • The Substitute(s, from, to) function replaces the first occurrence of the string from in the string s by the string to, and returns the resulting string. The original string s is not modified. Strings are immutable in Maple.
 • The SubstituteAll(s, from, to) function replaces all occurrences of from in s by to, and returns the resulting string. The original string s is not modified.
 • Only the first of overlapping occurrences of from in s is subject to replacement by to.
 • 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{Substitute}\left("abuvcd","uv","UV"\right)$
 ${"abUVcd"}$ (1)
 > $\mathrm{Substitute}\left("abvucd","uv","UV"\right)$
 ${"abvucd"}$ (2)
 > $\mathrm{Substitute}\left("abuvuv","uv","UV"\right)$
 ${"abUVuv"}$ (3)
 > $\mathrm{SubstituteAll}\left("abuvuv","uv","UV"\right)$
 ${"abUVUV"}$ (4)
 > $\mathrm{SubstituteAll}\left("abababababab","aba","ABA"\right)$
 ${"ABAbABAbABAb"}$ (5)