Template Engine language reference > Template Engine utilities > String functions > $string.substring

$string.substring
This function returns a new string which is a substring of the input string. The substring is specified by a start index and optionally an end index.
Syntax
$string.substring(<inStr>, <startIndex>[, <endIndex>])
inStr
startIndex
endIndex
Optional end index (zero based) that specifies the end of the substring. This index is the position of the first character after the substring, i.e. the first character to exclude from the substring.
If not set, the substring will include everything from startIndex to the end of the input string.
Note:
The index must not be < startIndex or > string.length.
Template examples
Example 102
Template
#set($str='Hello My Cruel World!')
#set($subStr=$string.substring($str, 6))
Original string: $str
Substring: $subStr
Output
Original string: Hello My Cruel World!
Substring: My Cruel World!
 
Example 103
Template
#set($str='Hello My Cruel World!')
#set($subStr=$string.substring($str, 6, 14))
Original string: $str
Substring: $subStr
Output
Original string: Hello My Cruel World!
Substring: My Cruel
 
OpenText StreamServe 5.6.2 Updated: 2018-01-26