substring() Method
Extract desired characters from a String (Length Fixed)
var SHRs, SMins, TimeStart = "10:30";
SHRs = TimeStart.substring(0,2); //0: Start, 2: End not included
SMins = TimeStart.substring(3,5);
Results:
SHRs: 10
SMins: 30
-- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
Syntax
stringVar.substring(start[, end])
start: An integer specifying the location of the beginning of the substring to be returned
end: An integer one greater than the location of the last character of the substring to be returned
Returns
A new string, of length end - start, containing the characters that appeared in the positions from start to end - 1 of stringVar.
Usage
This method returns a portion of stringVar, comprising the characters in stringVar at the positions start through end - 1. The character at the end position is not included in the returned string. If the end parameter is not used, stringVar.substring() returns the characters from start to the end of stringVar.
Source: Oracle Bookshelf v7.7
Comments
Post a Comment