beginsWithOneOf

Checks whether or not the first letter of a string begins with any of the passed string of characters, or single character.

Merely slices; does not decode the string and may thus give weird results on weird inputs.

@safe deprecated
bool
beginsWithOneOf
(
Haystack
Needle
)
(
const scope Haystack haystack
,
const scope Needle needles
)

Parameters

haystack Haystack

String to examine the start of, or single character.

needles Needle

String of characters to look for in the start of haystack, or a single character.

Return Value

Type: bool

true if the first character of haystack is also in needles, false if not.

Examples

assert("#channel".beginsWithOneOf("#%+"));
assert(!"#channel".beginsWithOneOf("~%+"));
assert("".beginsWithOneOf(""));
assert("abc".beginsWithOneOf(string.init));
assert(!"".beginsWithOneOf("abc"));

assert("abc".beginsWithOneOf('a'));
assert(!"abc".beginsWithOneOf('b'));
assert(!"abc".beginsWithOneOf(char.init));

assert('#'.beginsWithOneOf("#%+"));
assert(!'#'.beginsWithOneOf("~%+"));
assert('a'.beginsWithOneOf(string.init));
assert(!'d'.beginsWithOneOf("abc"));

Meta