munch

Finds the position pos of the first character in s that does not match pattern (in the terminology used by std.string.inPattern). Updates s = s[pos..$]. Returns the slice from the beginning of the original (before update) string up to, and excluding, pos.

The munch function is mostly convenient for skipping certain category of characters (e.g. whitespace) when parsing strings. (In such cases, the return value is not used.)

@safe pure @nogc
S1
munch
(
S1
S2
)
(
ref S1 s
,)

Examples

string s = "123abc";
string t = munch(s, "0123456789");
assert(t == "123" && s == "abc");
t = munch(s, "0123456789");
assert(t == "" && s == "abc");

Meta