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