StringSearch.locatePatternT

Scans "str" for "pattern" and returns the index of the first occurrence if found.

struct StringSearch(bool wide_char = false)
static
size_t
locatePatternT
(
istring pattern
)
(
in Char[] str
,
size_t start = 0
)

Parameters

str Char[]

string to scan

pattern

search pattern

start size_t

index to start searching from

Return Value

Type: size_t

If found, the index of the first occurrence, or the length of "str" otherwise.

Examples

test!("==")(StringSearch!().locatePatternT!("World")("Hello World!", 0), 6);
test!("==")(StringSearch!().locatePatternT!("[")("[Hello]", 1), "[Hello]".length);
// Crazy/inconsistent behavior: It should return 1
test!("==")(StringSearch!().locatePatternT!("[")("[", 1), 0);
// Fail unittests, because reasons
//test!("==")(StringSearch!().locatePattern("[", "[", 256), 0);

Meta