lastindexof
lastindexof(string
,substring
)
The LASTINDEXOF function has the following arguments:
string
The string to search for the substring.
substring
The substring to search for.
Return the starting position of the last occurrence a substring within a string.
The positon number is indexed starting at zero.
if the substring does not exist within the string then return -1.
Formula |
Description |
Result |
---|---|---|
lastindexof('foobar', 'bar') |
Return the locaton of 'bar' within 'foobar' |
3 |
lastindexof('foobar', 'foo') |
Return the locaton of 'foo' within 'foobar' |
0 |
lastindexof('foobar', 'baz') |
Return the locaton of 'baz' within 'foobar', but it does not exist |
-1 |
lastindexof('banana', 'na') |
Return the first locaton of 'na' within 'banana' |
4 |