Group: Difference between revisions

From Kolmafia
Jump to navigation Jump to search
imported>Bale
Created page with '{{ #vardefine:name|group}}{{ #vardefine:return_type|string}}{{ FunctionPage| name={{#var:name}}| function_category=String Handling Routines| function1={{Function| name={{#var:n…'
 
imported>Bale
No edit summary
Line 32: Line 32:
needscode=yes|
needscode=yes|


see_also={{SeeAlso|group_count|find}}|
}}
}}

Revision as of 05:13, 11 May 2010

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

group_count() | find()