Drop - Maple Help
For the best experience, we recommend viewing online help using Google Chrome or Microsoft Edge.
Our website is currently undergoing maintenance, which may result in occasional errors while browsing. We apologize for any inconvenience this may cause and are working swiftly to restore full functionality. Thank you for your patience.

Online Help

All Products    Maple    MapleSim


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 )

Take( s, delim )

Drop( s, len )

Drop( s, delim )

Parameters

s

-

Maple string

len

-

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

delim

-

string; set of characters (delimiters)

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.

• 

If the second argument is a string delim, it is interpreted as a set of delimiting characters. In this case, the Take( s, delim ) command returns the prefix of s consisting of characters not in the string delim. The Drop( s, delim ) command returns the suffix of s consisting of characters not in the string delim.

• 

Take and Drop satisfy the equation

s=catTakes,n,Drops,n

  

for all non-negative integers n.

• 

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

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)

Takeabcde,ec

ab

(6)

Dropabcde,ec

(7)

See Also

cat

seq

string

StringTools

StringTools[IsPrefix]

StringTools[Join]

StringTools[Split]

StringTools[SubString]