pub fn captures_from_pos<'t>(&self, text: &'t str, pos: usize) -> Result<Option<Captures<'t>>> {
        let named_groups = self.named_groups.clone();
        match &self.inner {
            RegexImpl::Wrap { inner, .. } => {
                let mut locations = inner.capture_locations();
                let result = inner.captures_read_at(&mut locations, text, pos);
                Ok(result.map(|_| Captures {
                    inner: CapturesImpl::Wrap { text, locations },
                    named_groups,
                }))
            }
            RegexImpl::Fancy {
                prog,
                n_groups,
                options,
                ..
            } => {
                let result = vm::run(prog, text, pos, 0, options)?;
                Ok(result.map(|mut saves| {
                    saves.truncate(n_groups * 2);
                    Captures {
                        inner: CapturesImpl::Fancy { text, saves },
                        named_groups,
                    }
                }))
            }
        }
    }
/// Returns the capture groups for the first match in `text`, starting from
/// the specified byte position `pos`.
///
/// # Examples
///
/// Finding captures starting at a position:
///
/// ```
/// # use fancy_regex::Regex;
/// let re = Regex::new(r"(?m:^)(\d+)").unwrap();
/// let text = "1 test 123\n2 foo";
/// let captures = re.captures_from_pos(text, 7).unwrap().unwrap();
///
/// let group = captures.get(1).unwrap();
/// assert_eq!(group.as_str(), "2");
/// assert_eq!(group.start(), 11);
/// assert_eq!(group.end(), 12);
/// ```
///
/// Note that in some cases this is not the same as using the `captures`
/// method and passing a slice of the string, see the capture that we get
/// when we do this:
///
/// ```
/// # use fancy_regex::Regex;
/// let re = Regex::new(r"(?m:^)(\d+)").unwrap();
/// let text = "1 test 123\n2 foo";
/// let captures = re.captures(&text[7..]).unwrap().unwrap();
/// assert_eq!(captures.get(1).unwrap().as_str(), "123");
/// ```
///
/// This matched the number "123" because it's at the beginning of the text
/// of the string slice.
///
Returns the capture groups for the first match in `text`, starting from
the specified byte position `pos`.
Returns the capture groups for the first match in ` text ` starting from the specified byte position ` pos ` .
pub fn captures_from_pos<'t>(&self, text: &'t str, pos: usize) -> Result<Option<Captures<'t>>> {
        let named_groups = self.named_groups.clone();
        match &self.inner {
            RegexImpl::Wrap { inner, .. } => {
                let mut locations = inner.capture_locations();
                let result = inner.captures_read_at(&mut locations, text, pos);
                Ok(result.map(|_| Captures {
                    inner: CapturesImpl::Wrap { text, locations },
                    named_groups,
                }))
            }
            RegexImpl::Fancy {
                prog,
                n_groups,
                options,
                ..
            } => {
                let result = vm::run(prog, text, pos, 0, options)?;
                Ok(result.map(|mut saves| {
                    saves.truncate(n_groups * 2);
                    Captures {
                        inner: CapturesImpl::Fancy { text, saves },
                        named_groups,
                    }
                }))
            }
        }
    }
pub fn captures_from_pos < ' t > ( & self , text : & ' t str , pos : usize ) -> Result < Option < Captures < ' t > > > { let named_groups = self . named_groups . clone ( ) ; match & self . inner { RegexImpl :: Wrap { inner , .. } => { let mut locations = inner . capture_locations ( ) ; let result = inner . captures_read_at ( & mut locations , text , pos ) ; Ok ( result . map ( | _ | Captures { inner : CapturesImpl :: Wrap { text , locations } , named_groups , } ) ) } RegexImpl :: Fancy { prog , n_groups , options , .. } => { let result = vm :: run ( prog , text , pos , 0 , options ) ? ; Ok ( result . map ( | mut saves | { saves . truncate ( n_groups * 2 ) ; Captures { inner : CapturesImpl :: Fancy { text , saves } , named_groups , } } ) ) } } }
Returns the capture groups for the first match in `text`, starting from
the specified byte position `pos`.
Returns the capture groups for the first match in ` text ` starting from the specified byte position ` pos ` .
&self
text
&'t str
pos
usize
&self
text
&'t str
pos
usize
examples
Finding captures starting at a position.


Finding captures starting at a position .
use fancy_regex::regex;




Note that in some cases this is not the same as using the `captures`
method and passing a slice of the string, see the capture that we get
when we do this.


Note that in some cases this is not the same as using the ` captures ` method and passing a slice of the string see the capture that we get when we do this .
use fancy_regex::regex;


This matched the number "123" because it's at the beginning of the text
of the string slice.
This matched the number " 123 " because it ' s at the beginning of the text of the string slice .