substring()

Returns the substring starting at byte position startindex and ending at endindex-1 or the end of the string.

Syntax

String  substring(Numeric startindex [, Numeric endindex ])
  1. startindex is the index in the current String where the substring starts. The first byte of a string is at position 0.
  2. endindex (optional) is the end index. If endindex is specified, the substring ends at endindex-1. If endindex is not specified, the substring extends to the end of the current String.

Example

The value of the String order_line.billState is "smiles" (indexes 012345).

The following code returns the substring "mile":

order_line.billState.substring(1,5) 

When calling the function with a single index, substring() returns an empty string if the index is out of range or if the input string is empty.

When calling the function with a startindex and a endindex, substring() returns an empty string if both indexes are out of range or if the input string is an empty string. If only the endindex is out of range, then the equivalent of calling substring() with the single index startindex is returned.