How to split a pipe(|), comma(,), tab, space,… separated string in ActionScript 3.0

August 21, 2008 at 12:51 pm (ActionScript, Flex) (, , )

To split a pipe(|), comma(,), tab, space,…. separated string into multiple string values in ActionScript 3.0, you will have to use the split() method of String class. Below is short example where in a pipe(|) seperated string is broken up into multiple values and pushed into an array.

var cities:String = "Bombay|Los Angeles|Moscow|London|Rio de Janeiro|Sydney";
var citiesArray:Array = cities.split("|");

trace(citiesArray); //Result: Bombay,Los Angeles,Moscow,London,Rio de Janeiro,Sydney

Permalink Leave a Comment