Function std.string.munch
This function is deprecated and will be removed May 2018.
Please use the functions in std
and std
instead. If you still need this function, it will be available in
undeaD.
S1 munch(S1, S2)
(
ref S1 s,
S2 pattern
) pure @nogc @safe;
Finds the position pos of the first character in s that does not match pattern (in the terminology used by
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.)
Example
string s = "123abc";
string t = munch(s, "0123456789");
assert(t == "123" && s == "abc");
t = munch(s, "0123456789");
assert(t == "" && s == "abc");
Authors
Walter Bright, Andrei Alexandrescu, Jonathan M Davis, and David L. 'SpottedTiger' Davis