import std.range: array; import std.ascii: isDigit; auto r = "012A"; assert(takeWhile!((a) => isDigit(a))(r).array == "012"); assert(r == "A"); assert(takeWhile!((a) => isDigit(a))(r).array == ""); assert(takeWhile!((a) => isDigit(a))("").array == "");
Returns a lazy input range that takes from the input while a predicate is verified and the input is not empty.