The index of the first byte in s at or after start_index, or -1 when there is none.
find_index_from_left :: (s: string, byte: u8, start_index := 0) -> s64
A negative start_index starts at the beginning.
Parameters
- s: string
- byte: u8
- start_index := 0
Returns
- s64
assert(find_index_from_left("a/b/c", #char "/") == 1);
assert(find_index_from_left("a/b/c", #char "/", 2) == 3);
assert(find_index_from_left("abc", #char "/") == -1);find_index_from_left :: (s: string, substring: string, start_index := 0) -> s64
The index where substring first appears in s, searching from start_index, or -1 when it does not.
An empty substring is never found, so the result is -1. start_index must not be negative, or an
assert fails (the byte overload accepts a negative one).
Parameters
- s: string
- substring: string
- start_index := 0
Returns
- s64
assert(find_index_from_left("banana", "ana") == 1);
assert(find_index_from_left("banana", "ana", 2) == 3);
assert(find_index_from_left("banana", "") == -1);