Group - Maple Help
For the best experience, we recommend viewing online help using Google Chrome or Microsoft Edge.

StringTools

 Group
 separate a string into groups based on a property

 Calling Sequence Group(p, s)

Parameters

 p - a predicate ( Maple procedure) to apply to string s s - string

Description

 • The Group(p,s) function returns an expression sequence of consecutive substrings of s that are maximal with respect to the individual characters satisfying, or not satisfying, the predicate p.
 • This procedure is analogous to the Group procedure in the ListTools package.
 • If the input string s is the empty string, for example, Group(IsDigit, "") then NULL is returned; see the last example.
 • 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):$
 > $s≔\mathrm{Random}\left(30,'\mathrm{alnum}'\right)$
 ${s}{≔}{"y58KNhcGK09mxYYTx7RAPYLR9k1yzm"}$ (1)
 > $\mathrm{Group}\left(\mathrm{IsDigit},s\right)$
 ${"y"}{,}{"58"}{,}{"KNhcGK"}{,}{"09"}{,}{"mxYYTx"}{,}{"7"}{,}{"RAPYLR"}{,}{"9"}{,}{"k"}{,}{"1"}{,}{"yzm"}$ (2)
 > $\mathrm{op}\left(\mathrm{map}\left(\mathrm{Join},\left[\mathrm{ListTools}:-\mathrm{Group}\left(\mathrm{IsDigit},\mathrm{Explode}\left(s\right)\right)\right],""\right)\right)$
 ${"y"}{,}{"58"}{,}{"KNhcGK"}{,}{"09"}{,}{"mxYYTx"}{,}{"7"}{,}{"RAPYLR"}{,}{"9"}{,}{"k"}{,}{"1"}{,}{"yzm"}$ (3)
 > $\mathrm{Group}\left(\mathrm{IsDigit},""\right)$