Byte_Search module

find

procedureextension4 overloadsSource

The first byte at or after start, or -1.

Example↗
Byte_Search :: #import "Extensions/Byte_Search";

assert(Byte_Search.find("a,b,c", #char ",") == 1);
assert(Byte_Search.find("a,b,c", #char ",", 2) == 3);
assert(Byte_Search.find("abc", #char ",") == -1);
find :: (text: string, byte: u8, start := 0) -> int

Parameters

text: string
byte: u8
start := 0

Returns

int
find :: (set: *Byte_Set, text: string, start := 0) -> int

The first byte of the set at or after start, or -1.

Parameters

set: *Byte_Set
text: string
start := 0

Returns

int
find :: (text: string, needle: string, start := 0) -> int

The first needle at or after start, or -1. An empty needle is found at start. Searching one needle many times is faster with a Finder.

Parameters

text: string
needle: string
start := 0

Returns

int
Example↗
Byte_Search :: #import "Extensions/Byte_Search";

assert(Byte_Search.find("one two one", "one", 1) == 8);
assert(Byte_Search.find("one two", "three") == -1);
find :: (finder: *Finder, text: string, start := 0) -> int

The first match at or after start, or -1.

Parameters

finder: *Finder
text: string
start := 0

Returns

int

See also