substring
This function is used by Ignition's Expression language.
Descriptionβ
Substring will return the portion of the string from the startIndex to the endIndex, or end of the string if endIndex is not specified. All indexes start at 0, so in the string "Test", "s" is at index 2. Indexes outside of the range of the string throw a StringIndexOutOfBoundsException.
Syntaxβ
substring(string, startIndex[, endIndex])
Parametersβ
| Type | Parameter | Description |
|---|---|---|
| String | string | The starting string. |
| Integer | startIndex | The index to start the substring at. |
| Integer | endIndex | Optional. The end index of the substring. |
Resultsβ
String - The substring from the start to end indexes of the specified string.
Examplesβ
Code Snippet
substring("unhappy", 2) //returns "happy"
Code Snippet
substring("hamburger", 4, 8) //Returns "urge" - note 8 is the index of "r", but the end index is exclusive.