String.last_index_of
String.last_index_of
Function
Returns the position of the last occurrence of the specified fragment.
Syntax
string.last_index_of(needle)
Parameters
| Parameters | Type | Required | Default value | Description |
|---|---|---|---|---|
| needle | Any | No | '' | The fragment to be found will be converted into a string first when called. |
Return value
| Type | Description |
|---|---|
| Int | Returns the starting byte position if found; returns -1 if not found. |
Example
text = 'bt-lang-bt' result = text.last_index_of('bt') // Output: 8 print result
Notes
- The return value is calculated as a UTF-8 byte offset.