Substring()

Returns a portion of a string, beginning at a specified character position. You can optionally specify the length of the substring to return.

The Substring() function has three parameters:

  • sourceString (string): Required. The string that contains the substring you want to identify.
  • startPosition (number): Required. The character position to begin the substring. If the specified character position exceeds the length of sourceString, the function returns an empty string.
  • substringLength (number): The number of characters to return after the initial character. If you don’t specify a length, the substring continues to the end of the string.

This example uses the Substring() function to remove part of a string of text and return the result.

The example returns the specified substring.