lastIndexOf
The lastIndexOf string task identifies the last occurrence of a specific character or group of characters within a given string. It is similar to the indexOf task, with the exception that it begins searching from the end of the input string (rather than the beginning). The search proceeds backwards starting from a position identified by the fromIndex value. This method returns a number (index) representing the position where the specified search value occurs.
The lastIndexOf task does not change the value of the original string.
Potential use case
Suppose you have a string that contains a date within it, and you need to locate the last slash / in the date value so that you can isolate the position of the “year” value. You could use the lastIndexOf task and extract it in a subsequent slice or substring task.
Properties
Example 1
In this example:
- The
strvariable has been statically set assales.department@itential.com. - The
searchValuevariable has been statically set as"."(a period). - The
fromIndexvariable has been intentionally left empty, indicating the search should start at the end of thestrvalue. - The output
indexvalue will be25because the first instance of a period".", starting from the end of the string, can be found at character position 25 (counting from the left) in thestrvariable.

Example 2
In this example:
- The
strvariable has been statically set assales.department@itential.com. - The
searchValuevariable has been statically set as"."(a period). - The
fromIndexvariable has been set to20, indicating the search should start at position 20 of thestrvalue and proceed to the left of that starting index position. - The output
indexvalue will be5because the first instance of a period".", starting left from position 20, can be found at character position 5 in thestrvariable.

Example 3
In this example:
- The
strvariable has been statically set assales.department@itential.com. - The
searchValuevariable has been statically set as"Z". - The
fromIndexvariable has been intentionally left empty, indicating the search should start at the end of thestrvalue. - The output
indexvalue will be-1, because there is no"Z"in thestrvalue.

Example 4
In this example:
- The
strvariable has been statically set assales.department@itential.com. - The
searchValuevariable has been statically set as"s". - The
fromIndexvariable has been set to-100. Since negative numbers are treated as0, the search will begin at the first letter of thestrvalue. - The output
indexvalue will be0in reference to the first letter of thestrvalue, which is the letter"s".
