StringTools - Maple Programming Help

Home : Support : Online Help : Programming : Names and Strings : StringTools Package : Case Conversion : StringTools/LowerCase

StringTools

 LowerCase
 change each alphabetic character in a string to lowercase
 UpperCase
 change each alphabetic character in a string to uppercase
 OtherCase
 change each alphabetic character in a string to the alternate case

 Calling Sequence LowerCase( s, rng ) UpperCase( s, rng ) OtherCase( s, rng )

Parameters

 s - Maple string rng - (optional) integer range

Description

 • The LowerCase(s) calling sequence changes each alphabetic character in the string s to lowercase and returns the result in a new string. The string s remains unchanged.
 • The UpperCase(s) calling sequence changes each alphabetic character in the string s to uppercase and returns the result in a new string. The string s remains unchanged.
 • The OtherCase(s) calling sequence changes each alphabetic character in the string s to the opposite case and returns the result in a new string. The string s remains unchanged.
 • See StringTools[IsLower] and StringTools[IsUpper] for definitions of lower and uppercase characters.
 • These commands all accept an optional, second argument rng, a range that specifies a substring of the input s to be affected by the operation. Only characters within the given range are changed.
 • 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{LowerCase}\left(""\right)$
 ${""}$ (1)
 > $\mathrm{LowerCase}\left("ABC"\right)$
 ${"abc"}$ (2)
 > $\mathrm{LowerCase}\left("ABC;!def"\right)$
 ${"abc;!def"}$ (3)
 > $\mathrm{LowerCase}\left("Impedance of Free Space"\right)$
 ${"impedance of free space"}$ (4)
 > $\mathrm{LowerCase}\left("ABCDEFGHIJ",3..8\right)$
 ${"ABcdefghIJ"}$ (5)
 > $\mathrm{UpperCase}\left(""\right)$
 ${""}$ (6)
 > $\mathrm{UpperCase}\left("abc"\right)$
 ${"ABC"}$ (7)
 > $\mathrm{UpperCase}\left("abc;!DEF"\right)$
 ${"ABC;!DEF"}$ (8)
 > $\mathrm{UpperCase}\left("Totally Random"\right)$
 ${"TOTALLY RANDOM"}$ (9)
 > $\mathrm{UpperCase}\left("abcdefghij",3..-2\right)$
 ${"abCDEFGHIJ"}$ (10)
 > $\mathrm{OtherCase}\left(""\right)$
 ${""}$ (11)
 > $\mathrm{OtherCase}\left("abc"\right)$
 ${"ABC"}$ (12)
 > $\mathrm{OtherCase}\left("DEF"\right)$
 ${"def"}$ (13)
 > $\mathrm{OtherCase}\left("abc;DEF"\right)$
 ${"ABC;def"}$ (14)
 > $\mathrm{OtherCase}\left("The Higher, The Fewer!"\right)$
 ${"tHE hIGHER, tHE fEWER!"}$ (15)

Note that LowerCase and UpperCase are not mutual inverses.

 > $s≔\mathrm{LowerCase}\left("abcDEF"\right)$
 ${s}{≔}{"abcdef"}$ (16)
 > $\mathrm{UpperCase}\left(s\right)$
 ${"ABCDEF"}$ (17)

However, LowerCase(UpperCase(Lowercase(s))) = LowerCase(s) for every s.

 > $\mathrm{LowerCase}\left(\mathrm{UpperCase}\left(\mathrm{LowerCase}\left("abcDEF"\right)\right)\right)$
 ${"abcdef"}$ (18)

The OtherCase command is an involution.

 > $\mathrm{OtherCase}\left(\mathrm{OtherCase}\left("abcDEF"\right)\right)$
 ${"abcDEF"}$ (19)