Skip to main content
Version: 8.1

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

    • 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.