Hyperlinkv0.8.0-beta.28

String

String.lastIndexOfconsteffect/String.ts:659
(searchString: string): (self: string) => Option.Option<number>

Returns the index of the last occurrence of a substring safely, or None if not found.

Example (Finding the last substring index)

import { pipe, String } from "effect"

pipe("abbbc", String.lastIndexOf("b")) // Option.some(3)
pipe("abbbc", String.lastIndexOf("d")) // Option.none()
searching
Source effect/String.ts:6592 lines
export const lastIndexOf = (searchString: string) => (self: string): Option.Option<number> =>
  Option.filter(Option.some(self.lastIndexOf(searchString)), number.isGreaterThanOrEqualTo(0))