View source code
Display the source code in std/regex.d from which this page was generated on
github.
Improve this page
Quickly fork, edit online, and submit a pull request for this page.
Requires a signed-in GitHub account. This works well for small changes.
If you'd like to make larger changes you may want to consider using
local clone.
Page wiki
View or edit the community-maintained wiki page associated with this page.
Struct std.regex.Captures
Captures
object
contains submatches captured during a call
to
or iteration over match
range.
RegexMatch
First element of range is the whole match
.
Properties
Name | Type | Description |
---|---|---|
back
[get]
|
R |
Range interface. |
captures
[get]
|
ref |
A hook for compatibility with original std.regex .
|
empty
[get]
|
bool |
Range interface. |
front
[get]
|
R |
Range interface. |
hit
[get]
|
R |
Slice of matched portion of input. |
length
[get]
|
size_t |
Number of matches in this object .
|
post
[get]
|
R |
Slice of input immediately after the match .
|
pre
[get]
|
R |
Slice of input prior to the match .
|
Methods
Name | Description |
---|---|
popBack
|
Range interface. |
popFront
|
Range interface. |
Templates
Name | Description |
---|---|
opCast
|
Explicit cast to bool. Useful as a shorthand for !(x.empty) in if and assert statements. |
opIndex
|
Range interface. |
opIndex
|
Lookup named submatch. |
Example
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"));
Authors
Dmitry Olshansky,
API and utility constructs are modeled after the original
by Walter Bright and Andrei Alexandrescu.
std.regex