StringTools
IsPrefix
test for an initial substring
IsSuffix
test for a terminal substring
Calling Sequence
Parameters
Description
Thread Safety
Examples
IsPrefix( s, t )
IsSuffix( s, t )
s, t
-
Maple strings
The IsPrefix( s, t ) command determines whether s is a prefix (initial substring) of t.
The string s is a prefix of the string t if s1=t1..n, for some integer 1≤n, or s is the empty string.
If s is a prefix of t, IsPrefix returns true. Otherwise, false is returned.
Note: The IsPrefix( s, t ) command is equivalent to the expression
member( s, [ seq( t[ 1 .. i ], i = 0 .. length( t ) ) ] ).
The IsSuffix( s, t ) command determines whether s is a suffix (terminal substring) of t.
If s is a suffix of t, IsSuffix returns true. Otherwise, false is returned.
Note: The IsSuffix( s, t ) command is equivalent to the expression
member( s, [ seq( t[ i .. -1 ], i = 1 .. 1 + length( t ) ) ] )
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.
The StringTools[IsPrefix] and StringTools[IsSuffix] commands are thread-safe as of Maple 15.
For more information on thread safety, see index/threadsafe.
with⁡StringTools:
IsPrefix⁡,abc
true
IsPrefix⁡a,abc
IsPrefix⁡ab,abc
IsPrefix⁡abc,abc
IsPrefix⁡abcd,abc
false
IsPrefix⁡ac,abc
IsSuffix⁡,abc
IsSuffix⁡c,abc
IsSuffix⁡bc,abc
IsSuffix⁡abc,abc
IsSuffix⁡xabc,abc
IsPrefix⁡foo,foobar
S≔seq⁡foobar1..i,i=0..length⁡foobar
S≔,f,fo,foo,foob,fooba,foobar
member⁡foo,S
s≔Random⁡100:
length⁡s
100
seq⁡IsSuffix⁡Drop⁡s,i,s,i=1..length⁡s
seq⁡IsPrefix⁡Take⁡s,i,s,i=1..length⁡s
See Also
length
member
seq
string
StringTools[Drop]
StringTools[Random]
StringTools[Select]
StringTools[Take]
Download Help Document