Returns the index inside of the string of tha last appearance of the specified substring.

The last ocurrence of an empty string "" this is considered to occur in the value of the index.length ().

1 string.lastIndexOf

<string.lastIndexOf>
    <text /> !
    <subtext /> !
</string.lastIndexOf>

Exceptions

requires 2 arguments, received: ...

The 2 entry parameters has not been specified.

Remarks

The character position indexes start counting from 0 and not from 1. If the substring of the second argument in the string or text of the first argument is not found, the script will return -1 as result. However, if the value of the second argument is null, the script will return as result the position 0.

Example

Visualize the initial position of the last of the argument 2 which can have the argument1.

Copy
<xsql-script name='string_lastIndexOf'>
    <body>
        <set name='a'>This IS a STRING OF characters, a STRING.</set>
        <set name='b'>STRING</set>
        <set name='c'>STRING</set>

        <println><string.lastIndexOf><a /><b /></string.lastIndexOf></println>
        <println><string.lastIndexOf><a /><c /></string.lastIndexOf></println>
    </body>
</xsql-script>

Returns:

Copy
-1
38