test for an initial substring - Maple Help

Online Help

All Products    Maple    MapleSim


Home : Support : Online Help : Programming : Names and Strings : StringTools Package : Comparisons : StringTools/IsPrefix

StringTools[IsPrefix] - test for an initial substring

StringTools[IsSuffix] - test for a terminal substring

Calling Sequence

IsPrefix( s, t )

IsSuffix( s, t )

Parameters

s, t

-

Maple strings

Description

• 

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 1n, 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 ) ) ] )

Thread Safety

• 

The StringTools[IsPrefix] and StringTools[IsSuffix] commands are thread-safe as of Maple 15.

• 

For more information on thread safety, see index/threadsafe.

Examples

withStringTools:

IsPrefix,abc

true

(1)

IsPrefixa,abc

true

(2)

IsPrefixab,abc

true

(3)

IsPrefixabc,abc

true

(4)

IsPrefixabcd,abc

false

(5)

IsPrefixac,abc

false

(6)

IsSuffix,abc

true

(7)

IsSuffixc,abc

true

(8)

IsSuffixbc,abc

true

(9)

IsSuffixabc,abc

true

(10)

IsSuffixxabc,abc

false

(11)

IsPrefixfoo,foobar

true

(12)

S:=seqfoobar1..i,i=0..lengthfoobar

S:=,f,fo,foo,foob,fooba,foobar

(13)

memberfoo,S

true

(14)

s:=Random100:

lengths

100

(15)

seqIsSuffixDrops,i,s,i=1..lengths

true

(16)

seqIsPrefixTakes,i,s,i=1..lengths

true

(17)

See Also

length, member, seq, string, StringTools, StringTools[Drop], StringTools[Random], StringTools[Select], StringTools[Take]


Download Help Document

Was this information helpful?



Please add your Comment (Optional)
E-mail Address (Optional)
What is ? This question helps us to combat spam