StringTools - Maple Programming Help

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

StringTools

 Snarf
 extract a prefix consisting of specified characters from a string

 Calling Sequence Snarf( s, cset )

Parameters

 s - Maple string cset - {string,symbol}; character set

Description

 • The Snarf( s, cset ) command returns the prefix of the string s consisting of characters from the character set, cset.
 • The character set, cset, may be specified either as a string, whose characters are taken to be those in the character set, or a symbol, such as lower which represents the set of lowercase alphabetic characters.
 • 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

 > $\mathrm{with}\left(\mathrm{StringTools}\right):$
 > $\mathrm{Snarf}\left("abcdEFGHijklm",'\mathrm{lower}'\right)$
 ${"abcd"}$ (1)
 > $\mathrm{Snarf}\left("abcdEFGHijklm","abcdefghijklmnopqrstuvwxyz"\right)$
 ${"abcd"}$ (2)
 > $\mathrm{Snarf}\left("abcdEFGHijklm","xyzab"\right)$
 ${"ab"}$ (3)
 > $\mathrm{Snarf}\left("relative/path/to/some/file",'\mathrm{\alpha }'\right)$
 ${"relative"}$ (4)

Compatibility

 • The StringTools[Snarf] command was introduced in Maple 18.