Group

From Kolmafia
Revision as of 17:04, 14 October 2014 by imported>Ulti (improving navigation)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigation Jump to search
needs(code_samples);

Function Syntax

string group(matcher pattern )

  • pattern is the regular expression to use

string group(matcher pattern ,int group )

  • pattern is the regular expression to use
  • group is the number of the capturing group to return

Returns the contents of an indicated capturing group or the entire pattern if not indicated. If the match was successful but the group specified failed to match any part of the input sequence, then the null string is returned. A group may match an empty string, so remember the null string is "\u0000".

Capturing groups are indexed from left to right, starting at one. Group zero indicates the entire pattern so group(m,0) is equivalent to group(m).

See Also

create_matcher() | group_count() | find() | group_string()