Captures
struct Captures
Represents the capture groups for a single match.
Capture groups refer to parts of a regex enclosed in parentheses. They can be optionally named. The purpose of capture groups is to be able to reference different parts of a match based on the original pattern.
Methods
Return length of Captures
.
Return length of Captures
.
Return length of Captures
.
nv
use std.regex.Regex;
let re = try! Regex.new("(\\d{4})-(\\d{2})-(\\d{2})");
let caps = re.captures("2010-03-14")!;
assert_eq caps.len(), 4;
Get item from Captures
by index, return a Match?
type.
Get item from Captures
by index, return a Match?
type.
Get item from Captures
by index, return a Match?
type.
nv
use std.regex.Regex;
let re = try! Regex.new("(\\d{4})-(\\d{2})-(\\d{2})");
let caps = re.captures("2010-03-14")!;
assert_eq caps.get(0)?.text, "2010-03-14";
assert_eq caps.get(0)?.start, 0;
assert_eq caps.get(0)?.end, 10;
assert_eq caps.get(1)?.text, "2010";
assert_eq caps.get(1)?.start, 0;
assert_eq caps.get(1)?.end, 4;