OxL Справочник OxL
РусскийEnglish

data Captures

A match with its capture groups; group 0 is the whole match, groups[i] is none when group i did not take part.

Example:

oxl✓ проверяется в CI
fn main() io {
  let re = Regex.compile("([a-z]+)@([a-z.]+)")!
  let c = re.captures("write to ann@example.org")!
  print("{c.groups.len()} {c.text(1)!} {c.text(2)!}")
}
Вывод
3 ann example.org
pub(api) data Captures

С версии. 1.0.0-beta

Поля

pub(api) groups: List<Match?>

Group 0 is the whole match; none marks a group that did not take part.

Методы

whole() -> Match
The whole match.
get(i: usize) -> Match?
Group i (0 = whole match).
text(i: usize) -> str?
Text of group i.
named(name: str) -> Match?
The group called name ((?<name>…)).

Определено в: std/core/text.oxl:1138

См. также