Topic group Related topics
Returns a substring derived from a specified character string.
<expC>.substring(<index1 expN>, <index2 expN>)
The string you want to extract characters from.
<index1 expN>, <index2 expnN>
Indexes into the string, which is indexed from left to right. The first character of the string is at index 0 and the last character is at index <expC>.length – 1.
This method is similar to the SUBSTR( ) function, but in addition to the syntactic difference of being a method instead of a function and the fact that the position is zero-based, the method takes a starting and ending position, while the function takes a start position and the number of character to extract.
<index1 expN> and <index2 expN> determine the position of the substring to extract. substring( ) begins at the lesser of the two indexes and extracts up to the character before the other index. If the two indexes are the same, substring( ) returns an empty string.
If the starting index is after the last character in the string, substring( ) returns an empty string.