Flash Player 5.
my_str.split("delimiter":String, [limit:Number]): Number
delimiter A string; the character or string at which my_str splits.
limit A number; the number of items to place into the array. This parameter is optional.
An array; an array containing the substrings of my_str.
Method; splits a String object into substrings by breaking it wherever the specified delimiter parameter occurs and returns the substrings in an array. If you use an empty string ("") as a delimiter, each character in the string is placed as an element in the array.
If the delimiter parameter is undefined, the entire string is placed into the first element of the returned array.
The following example returns an array with five elements:
var my_str:String = "P,A,T,S,Y";
var my_array:Array = my_str.split(",");
for (var i = 0; i<my_array.length; i++) {
trace(my_array[i]);
}
/* output:
P
A
T
S
Y
*/
The following example returns an array with two elements, "P" and "A":
var my_str:String = "P,A,T,S,Y";
var my_array:Array = my_str.split(",", 2);
trace(my_array); // output: P,A
The following example shows that if you use an empty string ("") for the delimiter parameter, each character in the string is placed as an element in the array:
var my_str:String = new String("Joe");
var my_array:Array = my_str.split("");
for (var i = 0; i<my_array.length; i++) {
trace(my_array[i]);
}
/* output:
J
o
e
*/
An example is also in the Strings.fla file in the HelpExamples folder. The following list gives typical paths to this folder:
Array.join()
RSS feed | Send me an e-mail when comments are added to this page | Comment Report
Current page: http://livedocs.adobe.com/flash/mx2004/main_7_2/00001715.html
Comments
MotionMaker said on Aug 20, 2004 at 8:57 AM : Mister Neb said on Aug 27, 2004 at 3:13 PM :