Difference between revisions of "Split string"

From Kolmafia
Jump to navigation Jump to search
imported>PhilmASTErpLus
(Discovery: split_string uses regular expressions! See http://kolmafia.us/showthread.php?t=2473)
imported>Heeheehee
m (Technicality -- "maps" should've been used here. Maps are different from arrays in that they are of variable length. Gogo correctness!)
Line 30: Line 30:
 
needscode=yes|
 
needscode=yes|
  
special=This function technically returns an array, not an aggregate. The information in both is accessed in the same way. However, you cannot add new key-value pairs to an array (it's length is static once set).|
+
special=This function technically returns an array, not a map. The information in both is accessed in the same way. However, you cannot add new key-value pairs to an array (it's length is static once set).|
 
}}
 
}}
  
 
[[Category:String Handling Routines]]
 
[[Category:String Handling Routines]]

Revision as of 15:27, 9 July 2010

needs(code_samples);

Function Syntax

string [int] split_string(string source )

string [int] split_string(string source ,string delimiter )

  • source is the string to split
  • delimiter is the (optional) regular expression to split with

Returns an array of your source, split by either delimiter or by line-breaks if not supplied.

Special

This function technically returns an array, not a map. The information in both is accessed in the same way. However, you cannot add new key-value pairs to an array (it's length is static once set).