MCPcopy Create free account
hub / github.com/davidblewett/rure-python / captures

Method captures

regex/src/re_unicode.rs:311–318  ·  view source on GitHub ↗

Returns the capture groups corresponding to the leftmost-first match in `text`. Capture group `0` always corresponds to the entire match. If no match is found, then `None` is returned. You should only use `captures` if you need access to the location of capturing group matches. Otherwise, `find` is faster for discovering the location of the overall match. # Examples Say you have some text with

(&self, text: &'t str)

Source from the content-addressed store, hash-verified

309 /// The `0`th capture group is always unnamed, so it must always be
310 /// accessed with `get(0)` or `[0]`.
311 pub fn captures<'t>(&self, text: &'t str) -> Option<Captures<'t>> {
312 let mut locs = self.capture_locations();
313 self.captures_read_at(&mut locs, text, 0).map(move |_| Captures {
314 text: text,
315 locs: locs.0,
316 named_groups: self.0.capture_name_idx().clone(),
317 })
318 }
319
320 /// Returns an iterator over all the non-overlapping capture groups matched
321 /// in `text`. This is operationally the same as `find_iter`, except it

Callers

nothing calls this directly

Calls 5

mapMethod · 0.80
cloneMethod · 0.80
capture_name_idxMethod · 0.80
capture_locationsMethod · 0.45
captures_read_atMethod · 0.45

Tested by

no test coverage detected