StringTools
Select
select characters from a string
Remove
remove characters from a string
SelectRemove
split a string into two according to a predicate
Calling Sequence
Parameters
Description
Examples
Select(p, s)
Remove(p, s)
SelectRemove(p, s)
p
-
Maple procedure that evaluates to either true or false; predicate that characters in the string must satisfy, or a character class specfication that constitute an implicit predicate
s
Maple string
The Select( p, s ) function returns the characters in string s that satisfy the specified predicate p.
The first argument p must be a Maple procedure that returns either true or false. Procedure p is applied to each character in string s. The Select function returns the concatenation of all the characters from it for which the procedure p returns true.
The Remove( p, s ) function returns the characters in string s that do not satisfy the specified predicate p.
The first argument p must be a Maple procedure that returns either true or false. Procedure p is applied to each character in string s. The Remove function returns the concatenation of all the characters from it for which the procedure p returns false.
The SelectRemove( p, s ) function is equivalent to:
SelectRemove⁡p,s=Select⁡p,s,Remove⁡p,s
If p returns a value other than true or false, an exception is raised.
Instead of a predicate, the argument p may be a character class that defines an implicit predicate equivalent to membership in the string p. That is, a character in the string s is deemed to satisfy the implicit predicate if that character belongs to character class defined by p, in this case. (See ExpandCharacterClass for a description of character classes.)
These functions are part of the StringTools package, and so they can be used in the form Select(..) only after executing the command with(StringTools). However, they can always be accessed through the long form of the command by using the form StringTools[Select](..).
Note: These functions are analogous to the select, remove, and selectremove functions.
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.
with⁡StringTools:
Select⁡IsUpper,Capitalize⁡This is a test.
TIAT
s≔Random⁡1000:
t≔Select⁡IsAlphaNumeric,s:
length⁡s,length⁡t
1000,258
Remove⁡IsVowel,Some people contend that in the English language vowels are superfluous.
Sm ppl cntnd tht n th nglsh lngg vwls r sprfls.
Remove⁡aeiouAEIOU,Some people contend that in the English language vowels are superfluous.
Remove⁡vowel,Some people contend that in the English language vowels are superfluous.
SelectRemove⁡IsUpper,Capitalize⁡This is a test.
TIAT,his s est.
See Also
length
member
remove
select
selectremove
StringTools[Capitalize]
StringTools[ExpandCharacterClass]
StringTools[IsAlphaNumeric]
StringTools[IsUpper]
StringTools[IsVowel]
StringTools[Random]
Download Help Document