Module:...Capture(3)
π NAME π
Okay so bestie, this is Module::Generic::RegexpCapture β it's a Regexp Result Object, and it's literally the little cutie that holds your regex results so you can go back and grab them whenever. No cap. (Also hi, this is from the User Contributed Perl Documentation, and the page header says Module:...Capture(3) β iykyk.)
β¨ SYNOPSIS β¨
if( my $rv = $s->replace( qr/[[:blank:]\h]+/, '_' ) )
{
my $first_match = $rv->capture->first;
# Do something
}
See that? $rv->capture->first β chaining is the whole vibe here π¦
π VERSION π
v0.1.0
πΈ DESCRIPTION πΈ
So this is a regular expression result object class, periodt. The way it works: it lets you run a regular expression using chaining, and then later you can pull out your capture groups from this class object. It's giving "hold my results so I don't have to think about them right now" energy π
π METHODS π
π« capture
This returns an array object (Module::Generic::Array) of capture groups β equivalent to "@{^CAPTURE}" π«Ά
Want the equivalent of $1? Easy:
$re->capture->first;
# or
$re->capture->get(0);
And $2:
$re->capture->second;
# or
$re->capture->get(1);
# etc...
Literally so convenient, ngl π₯
π« matched
Returns an integer value representing the number of successful match in the regular expression. It's equivalent to doing:
my $n = $string =~ s/[[:blank:]\h]+//gs;
And $n would contain the same value as $re->matched β
π« name
If your regular expression was using named captures, such as
qr/(?<my_name>.*?)/
then this method will return an object whose methods are named after each named capture. For example, using the case above:
my $str = $re->name->my_name;
Named captures really said "I'll be the main character" π
π« result
Returns an array object (Module::Generic::Array) of returned values from the regular expression. This is equivalent to:
my @result = $string =~ s/[[:blank:]\h]+//gs;
π¨ Okay important thing bestie, listen up:resultcan return an array object with one empty entry. That's just what perl returns in list context when there is no match. So if you actually want to check whether your regular expression matched or not, usematchedinstead. Fr fr, don't get caught out by this one π
π¦ SEE ALSO π¦
"like" in Module::Generic::Scalar"match" in Module::Generic::Scalar"replace" in Module::Generic::Scalar
Go read those too, they're iconic β¨
π AUTHOR π
Jacques Deguest <jack@deguest.jp>
π COPYRIGHT & LICENSE π
Copyright (c) 2021-2024 DEGUEST Pte. Ltd.
You can use, copy, modify and redistribute this package and associated files under the same terms as Perl itself.
Okay that's the whole page, you ate that π
Sign-off time: this lovely little doc is running on perl v5.42.2, dated 2026-02-15, and it's Module:...Capture(3) all the way down. Byeee ππ¦π
π¦ where this page comes from
- alpine 3.24: perl-module-generic-doc 1.1.3-r1 Β· GPL-1.0-or-later OR Artistic-1.0-Perl
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms