Skip to main content

lastIndexOf

Retrieves the index of last occurrence of a substring in a string.

lastIndexOf(searchString, substring)

Parameters#

  • searchString: The string to search within
  • substring: The string to find in searchString

Returns#

  • The index within searchString of the last occurrence of the specified substring.

Example#

print(lastIndexOf('Happy world, healthy world', 'world')) # prints, 21