pub fn nth_match_group(group: NonZeroUsize) -> Cow<'static, str>Expand description
Global variable name for the nth capture group from a Regexp match.
Ruby tags captures from the last Regexp match with global variables of the
form $1, $2, $3, etc. This function accepts NonZeroUsize because
$0 is not a valid Regexp capture group name in Ruby ($0 refers to the
program name).
This function may return either a &'static str or an owned String for
a given capture group name. This function differs from
nth_match_group_bytes by returning Cow<'static, str>.
ยงExamples
use core::num::NonZeroUsize;
use spinoso_regexp::nth_match_group;
let group = NonZeroUsize::new(1)?;
let global_name = nth_match_group(group);
assert_eq!(&*global_name, "$1");
let group = NonZeroUsize::new(27)?;
let global_name = nth_match_group(group);
assert_eq!(&*global_name, "$27");