Next: substring
Up: Methods
Previous: split
Contents
substr
Description
Returns a substring beginning at a specified location and having a specified length.
Syntax
- StringObj.split(start, [length])
- "String Literal".split(start, [length])
Parameters
- start
- An integer that indicates the position of the first character in stringObj to be used to create the substring. If start is a negative number, the starting position is determined from the end of the string, where the -1 is the last character.
- length
- optional. The number of characters in the substring being created. If length is not specified, the substring includes all of the characters from the start to the end of the string.
Returns
If length is zero or negative, an empty string is returned. If not specified, the substring continues to the end of stringvar. The substr method does not change the string specified by stringObj, it returns a new string.
Example
s = "This is an example for String.substr";
r = s.substr(0, 4);
trace(r);
//output: This
Copyright ©2000-2010 Shanghai TopCMM Software Technologies. All Rights Reserved.