String.slice(start,end)
Top  Previous  Next


SWiSH Player Support
SWF5 or later - Supported Internally

Syntax
myString.slice(start [, end])

Arguments
myString: The string variable.

start: A number specifying the index of the starting point for the slice. If start is a negative number, the starting point is determined from the end of the string, where -1 is the last character. 0 represents the first character.

end: A number specifying the index of the ending point for the slice. If end is not specified, the slice includes all characters from start to the end of the string. If end is a negative number, the ending point is determined from the end of the string, where -1 is the last character.

Returns
Substring specified by start, end Arguments.

Description
Method: Extracts a slice, or substring, of the specified String Object; then returns it as a new string without modifying the original String Object. The returned string includes the start character and all characters up to (but not including) the end character.

Sample
onLoad () {
    str = "abcdefgbc";
    trace ("[" + str.slice(3,6) + "]");   // returns [def]
}