Attribution: I didn't write this myself, I found it in a comment on one of the Actionscript on-line documentation pages.
function explode(separator:String, string:String) { var list = new Array(); if (separator == null) return false; if (string == null) return false; var currentStringPosition = 0; while (currentStringPosition<string.length) { var nextIndex = string.indexOf(separator, currentStringPosition); if (nextIndex == -1) break; var word = string.slice(currentStringPosition, nextIndex); list.push(word); currentStringPosition = nextIndex+1; } if (list.length<1) { list.push(string); } else { list.push(string.slice(currentStringPosition, string.length)); } return list; }
var myString = "hello,world";
var myStringArray = myString.split(",");