String module

find_index_from_right

procedure · 2 overloadsSource

The index of the last byte in s, or -1 when there is none.

find_index_from_right :: (s: string, byte: u8) -> s64

Parameters

s: string
byte: u8

Returns

s64
ExampleOpen in playground ↗
assert(find_index_from_right("a/b/c", #char "/") == 3);
find_index_from_right :: (s: string, substring: string) -> s64

The index where substring last appears in s, or -1 when it does not. An empty substring is never found.

Matches may overlap: the last ana in banana starts at 3.

Parameters

s: string
substring: string

Returns

s64
ExampleOpen in playground ↗
assert(find_index_from_right("banana", "ana") == 3);

See also