String module

contains

procedure · 2 overloadsSource

Whether substring appears in s, and the part of s after its first match. When it does not appear the remainder is empty. An empty substring is never found. The remainder points into s.

contains :: (s: string, substring: string) -> (found: bool, remainder: string)

Parameters

s: string
substring: string

Returns

found: bool
remainder: string
ExampleOpen in playground ↗
found, rest := contains("copper/blue", "per/");
assert(found && rest == "blue");
contains :: (s: string, char: u8) -> (found: bool, remainder: string)

Whether the byte char appears in s, and the part of s after its first occurrence.

Parameters

s: string
char: u8

Returns

found: bool
remainder: string
ExampleOpen in playground ↗
found, rest := contains("key=value", #char "=");
assert(found && rest == "value");

See also