Group string: Difference between revisions
imported>Jasonharper No edit summary |
imported>StDoodle mNo edit summary |
||
Line 1: | Line 1: | ||
{{#vardefine:name|group_string}} | {{ | ||
{{#vardefine:return_type|string [int, int]}} | #vardefine:name|group_string}}{{ | ||
{{#vardefine:aggregate|yes}} | #vardefine:return_type|string [int, int]}}{{ | ||
#vardefine:aggregate|yes}}{{ | |||
FunctionPage| | |||
name={{#var:name}}| | name={{#var:name}}| | ||
function_category=String Handling Routines| | function_category=String Handling Routines| |
Revision as of 21:43, 8 March 2010
Function Syntax
string [int, int] group_string(string group_me ,string group_by )
- group_me is the string to split into groups
- group_by is the regular expression to group by
This function finds all (non-overlapping) matches of the regular expression group_by within the string group_me. A 2-dimensional array of matching strings is returned. The first index is the number of the match, starting with 0 for the first match. The second index is the number of the group within each match, with exactly the same meaning as the 2nd parameter to group(): element 0 is the entire text matched by the regular expression, element 1 is the text matched by the first set of grouping parentheses within the expression, element 2 is the second set of grouping parentheses, and so on.
More Information
See this thread for details.
Attention KoLmafia Experts!
We need your help; some details of this function's operation are unknown or unclear.
The following specific questions have been raised:
- The regex isn't too hard to parse, but the results are.
- For results, I always see [int,0] and [int,1] keys; huh?