By Daniel · January 11, 2009
Splits a string into parts of size part_size and returns the pieces in a ds_list. For example, string_split("abcdefg", 2) yields [ab, cd, ef, g].
/* string_split(str, part_size)
*
* Splits a string into parts of size part_size and returns the pieces
* in a ds_list.
*
* For example, string_split("abcdefg", 2) yields [ab, cd, ef, g].
*/
var parts, size, i;
parts = ds_list_create();
size = string_length(argument0);
for (i = 1; i <= size; i += argument1)
ds_list_add(parts, string_copy(argument0, i, argument1));
return parts;
Categories: String handling
There are no comments to display.
You must be signed in to post comments.