Flash as string. split () character cutting Function Details

Source: Internet
Author: User

Split (String. split method)
Public split (delimiter: String, [limit: Number]): Array

Disconnects the String object from all locations where the specified delimiter parameter appears, splits it into substrings, and returns the substrings in array form. If an empty string ("") is used as the separator, each character in the string is placed as an element in the array.

If the delimiter parameter is not defined, the entire string is placed in the first element of the returned array.

Availability: ActionScript 1.0; Flash Player 5

Parameters
Delimiter: String-a String; a character or String at which my_str is split.

Limit: Number [optional]-Number of projects to be placed in the array.

Return
Array-an Array containing the child string of my_str.

Example
The following example returns an array containing five elements:

The code is as follows: Copy code

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 containing two elements ("P" and ":

The code is as follows: Copy code
Var my_str: String = "P, A, T, S, Y ";
Var my_array: Array = my_str.split (",", 2 );
Trace (my_array); // output: P,

The following example shows that if you use a null string ("") for the delimiter parameter, each character in the string is placed as an element in an array:

The code is as follows: Copy code

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

There is also an example in the Strings. fla file in the sample folder of the ActionScript file. The following list specifies the typical path to this folder:

Windows: boot drive Program filesm1_mediaflash 8 Samples and TutorialsSamplesActionScript
Macintosh: Macintosh HD/Applications/Macromedia Flash 8/Samples and Tutorials/Samples/ActionScript

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.