SCRIPT(`
var index = names.lastIndexOf("apple");
if(index >= 0) index++; // We increase the index to get a number starting from 1.
index;
`, "names", [Field 1])
findLastIndexOf_example.iok | 7K |
/*Declare the value and the field to search, in this case, searching for apple and Field 1*/
DECLARE(valueToSearch, "apple", fieldToSearch, [Field 1],
/*Store the result in the variable called "index". This uses a SEARCHREGEX function to find the index that doesn't have another occurrence of the search string anywhere after the string, in other words it looks for index of apple, only if there is no other words apple till the end of the string. */
DECLARE(index, SEARCHREGEX(valueToSearch+"((?!"+valueToSearch+").)*$", fieldToSearch, 1), index))
It looks like you're new here. If you want to get involved, click one of these buttons!