Splitting Strings in Flex ActionScript: split method

Using Split method on a given String, you can get an array of Substrings. Each substring is formed from the given String by spliting them according to another given string, or expression. That means, the another string separates or splits the mother-String and split it into array of Substrings.


var myStr:String = "first_second_third";
var subStr:Array = myStr.split("_");

Now subStr[0] will contain “first”, subStr[2] will contain “third”;

More Practical Example:

import flash.display.Sprite;
public class Main extends Sprite{
public function Main(){
var filename:String = "document.jpg";
var nameParts:Array = filename.split(".");
var extensionless:String = nameParts[0];
trace ("The filename is " + extensionless);
var extension:String = nameParts[1];
trace ("The file extension is " + extension);

You can see following Useful Links:


This article was previously published at my Progmaatic Blog.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s