StringTools - Maple Programming Help

Online Help

All Products    Maple    MapleSim


Home : Support : Online Help : Programming : Names and Strings : StringTools Package : Filter Operations : StringTools/Take

StringTools

  

Take

  

extract a prefix from a string

  

Drop

  

remove a prefix from a string

 

Calling Sequence

Parameters

Description

Examples

Calling Sequence

Take( s, len )

Drop( s, len )

Parameters

s

-

Maple string

len

-

non-negative integer; length of prefix to extract or remove

Description

• 

The Take(s, len) command returns the prefix of length len from string s.

  

If s has at least len characters, then the substring of s consisting of the first len characters of s is returned. That is, the string s1..len is returned. If s has length less than len, then s is returned.

• 

The Drop(s, len) command removes the prefix of length len from string s.

  

If the length of s is greater than or equal to len, then the string s1+len..1 is returned. If the length of s is less than len, then an empty string is returned.

• 

Take and Drop satisfy the equation

s=catTakes,n,Drops,n

  

for all non-negative integers n.

Examples

withStringTools:

seqTakeabcde,i,i=0..6

,a,ab,abc,abcd,abcde,abcde

(1)

seqTake,i,i=0..6

,,,,,,

(2)

seqDropabcde,i,i=0..6

abcde,bcde,cde,de,e,,

(3)

seqDrop,i,i=0..6

,,,,,,

(4)

seqcatTakeabcde,i,Dropabcde,i,i=0..6

abcde,abcde,abcde,abcde,abcde,abcde,abcde

(5)

See Also

cat

seq

string

StringTools

StringTools[IsPrefix]

StringTools[Join]

StringTools[Split]

StringTools[SubString]