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

Method pos

regex/src/re_trait.rs:29–35  ·  view source on GitHub ↗

Returns the start and end positions of the Nth capture group. Returns `None` if `i` is not a valid capture group or if the capture group did not match anything. The positions returned are *always* byte indices with respect to the original string matched.

(&self, i: usize)

Source from the content-addressed store, hash-verified

27 /// not match anything. The positions returned are *always* byte indices
28 /// with respect to the original string matched.
29 pub fn pos(&self, i: usize) -> Option<(usize, usize)> {
30 let (s, e) = (i * 2, i * 2 + 1);
31 match (self.0.get(s), self.0.get(e)) {
32 (Some(&Some(s)), Some(&Some(e))) => Some((s, e)),
33 _ => None,
34 }
35 }
36
37 /// Creates an iterator of all the capture group positions in order of
38 /// appearance in the regular expression. Positions are byte indices

Callers 1

nextMethod · 0.45

Calls 1

getMethod · 0.45

Tested by

no test coverage detected