Group string: Difference between revisions

From Kolmafia
Jump to navigation Jump to search
imported>StDoodle
mNo edit summary
imported>StDoodle
No edit summary
Line 1: Line 1:
{{RFI|I can understand regex if I walk through it slowly; but I can't for the life of me understand the return mapping.--[[User:StDoodle|StDoodle]] 04:55, 3 March 2010 (UTC)}}
string [int,int] group_string( string, string )
 
{{#vardefine:name|group_string}}
{{#vardefine:return_type|string [int, int]}}
{{#vardefine:aggregate|yes}}
 
{{FunctionPage|
name={{#var:name}}|
function_category=String Handling Routines|
 
function1={{Function|
name={{#var:name}}|
aggregate={{#var:aggregate}}|
return_type={{#var:return_type}}|
return_also={{#var:return_also}}|
parameter1={{Param|string|group_me}}|
parameter2={{Param|string|group_by}}|
p1desc={{Pspan|group_me}} is the string to split into groups|
p2desc={{Pspan|group_by}} is the regular expression to group by|
}}|
 
function_description=This function returns a map keyed by an integer pair of text in {{pspan|group_me}} matching the regular expression {{pspan|group_by}}. Exactly how is unclear.|
 
needscode=yes|
 
more_info= See [http://kolmafia.us/showthread.php?t=318 this thread] for details.|
}}
 
{{RFI|The regex isn't too hard to parse, but the results are.|For results, I always see [int,0] and [int,1] keys; huh?}}

Revision as of 16:02, 5 March 2010

string [int,int] group_string( string, string )




needs(code_samples);

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 returns a map keyed by an integer pair of text in group_me matching the regular expression group_by. Exactly how is unclear.

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?