String.substring()
Availability
Flash Player 5.
Usage
my_str.substring(start:Number, [end:Number]) : String
Parameters
A number; an integer that indicates the position of the first character of
start
create the substring. Valid values for
negative value, 0 is used.
A number; an integer that is 1+ the index of the last character in
end
Valid values for
end
is not included in the extracted string. If this parameter is omitted,
parameter is a negative value, 0 is used.
Returns
String: a substring of the specified string.
Description
Method; returns a string comprising the characters between the points specified by the
parameters. If the
end
string. If the value of
value of
is greater than the value of
start
the function executes and the original value is unchanged.
Example
The following example shows how to use
var my_str:String = "Hello world";
var mySubstring:String = my_str.substring(6,11);
trace(mySubstring); // output: world
The following example shows what happens if a negative
var my_str:String = "Hello world";
var mySubstring:String = my_str.substring(-5,5);
trace(mySubstring); // output: Hello
418
Chapter 6: ActionScript Core Classes
start
are 1 through
String.length
parameter is not specified, the end of the substring is the end of the
end
equals the value of
start
substring()
are 0 through
String.length
. The character indexed by the
, the method returns an empty string. If the
end
, the parameters are automatically swapped before
end
:
start
my_str
- 1. If
start
to be extracted.
my_str
end
is used. If this
String.length
parameter is used:
used to
is a
parameter
and
start
Need help?
Do you have a question about the FLEX-FLEX ACTIONSCRIPT LANGUAGE and is the answer not in the manual?