extract a prefix from a string
remove a prefix from a string
Take( s, len )
Take( s, delim )
Drop( s, len )
Drop( s, delim )
non-negative integer; length of prefix to extract or remove
string; set of characters (delimiters)
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
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.
Download Help Document