You are not logged in.
Pages: 1
/// string_split(str, substr)
/* Description: divides string "str" at delimiter "substr" and
returns an array containing all of the pieces. */
var str = argument0, sub = argument1, result, i = 0, pos = string_pos(sub, str);
while(pos) {
result[i++] = string_delete(str, pos, string_length(str));
str = string_delete(str, 1, pos);
pos = string_pos(sub, str);
}
result[i] = str;
return result;
Example code:
var words = string_split("the sky is blue", " ");
show_debug_message(words[1]); // This will output "sky"
Offline
should be:
}
if (str != "") {
result[i] = str;
}
return result;
in case of "the sky is blue ".
Offline
Pages: 1