string.slice()
Get the substring between two indexes of a String.
Description
Extracts the substring between provided two zero-based offset indexes of the calling String.
Parameters
Parameter | Type | Required | Description |
---|---|---|---|
start |
true |
Starting index of the substring to extract (inclusive). The index is a zero-based offset, counted from the left. If this start index is greater than or equal to the length of the String, the method returns an empty String. |
|
end |
true |
Ending index of the substring to extract (exclusive). The index is a zero-based offset, counted from the left. If this end index is less than the start index, the method returns an empty String. |
Examples
Get the subString from index 9 up to, but not including, 15:
"HTTP/1.1 200 OK".slice(9, 15)
"200 OK"