Next: , Previous: Set, Up: Expressions



6.4.10 The Function substring

The expression substring(string, start_index, end_index) yields the substring of string that starts at start_index and ends at end_index, both inclusive. A positive index counts from the string start: 1L is the index of the first character; a negative index counts from the string end: 1R is the index of the last character. If end_index is omitted, it is assumed to be the same as start_index, so substring(string, index) yields the character at index in string. If end_index is less than start_index, the function yields an empty string.