This function searches for a specific substring in the input string, and returns the position (zero based index) of the last occurrence of the specified substring. If the substring is not found, it returns -1. You can add an optional index argument to this function to specify the position where to start in the input string.
Note: The search is done backwards, starting from the last character in the input string or from the start index if specified.$string.lastIndexOf(<inStr>, <subStr>[, <index>])
inStrsubStrindex Optional start index (zero based) that sets the start position for the search. If not set, the start position is the last character in the input string (i.e. index=string.length-1).
Example 100 #set($str='But to be able to do this you have to do that!')
#set($pos=$string.lastIndexOf($str, 'to'))
Position is: $posPosition is: 35
Example 101 #set($str='But to be able to do this you have to do that!')
#set($pos=$string.lastIndexOf($str, 'to', 20))
Position is: $posPosition is: 15
| OpenText StreamServe 5.6.2 | Updated: 2018-01-26 |