Explicit cast to bool. Useful as a shorthand for !(x.empty) in if and assert statements.
Range interface.
Lookup named submatch.
Range interface.
A hook for compatibility with original std.regex.
Range interface.
Range interface.
Slice of matched portion of input.
Number of matches in this object.
Slice of input immediately after the match.
Slice of input prior to the match.
Number of pattern matched counting, where 1 - the first pattern. Returns 0 on no match.
import std.range.primitives : popFrontN; auto c = matchFirst("@abc#", regex(`(\w)(\w)(\w)`)); assert(c.pre == "@"); // Part of input preceding match assert(c.post == "#"); // Immediately after match assert(c.hit == c[0] && c.hit == "abc"); // The whole match assert(c[2] == "b"); assert(c.front == "abc"); c.popFront(); assert(c.front == "a"); assert(c.back == "c"); c.popBack(); assert(c.back == "b"); popFrontN(c, 2); assert(c.empty); assert(!matchFirst("nothing", "something")); // Captures that are not matched will be null. c = matchFirst("ac", regex(`a(b)?c`)); assert(c); assert(!c[1]);
Captures object contains submatches captured during a call to match or iteration over RegexMatch range.
First element of range is the whole match.