Group string: Difference between revisions
imported>StDoodle mNo edit summary |
imported>Jasonharper No edit summary |
||
Line 18: | Line 18: | ||
}}| | }}| | ||
function_description=This function | function_description=This function finds all (non-overlapping) matches of the regular expression {{pspan|group_by}} within the string {{pspan|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|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.| | ||
needscode=yes| | needscode=yes| |
Revision as of 16:41, 5 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?