Name
SPVM::Regex::Match - Regex Matching Result
Description
The Regex::Match class of SPVM has methods to manipulate a regex matching result.
Usage
use Regex::Match;
my $match = Regex::Match->new({success => 1, captures => [(string)"abc", "def"]});
my $cap1 = $match->cap1;
my $cap2 = $match->cap2;
my $cpa3 = $match->cap3;
Fields
success
has success : ro byte;
If a pattern match is successful, this field is set to 1.
captures
has captures : ro string[];
The captured strings.
match_start
has match_start : ro int
;
The start offset of the matched string.
match_length
has match_length : ro int
;
The length of the matched string.
Class Methods
new
static method new : Regex::Match ($options : object[] = undef);
Creates a new Regex::Match object, and returns it.
Options:
success
: IntSets the
success
field.match_start
: IntSets the
match_start
field.match_length
: IntSets the
match_length
field.captures
: string[]Sets the
captures
field.
Examples:
my $match = Regex::Match->new({success => 1, captures => [(string)"abc", "def"]});
Instance Methods
captures_length
method captures_length : int ();
Gets the length of the "captures" field.
cap
method cap : string ($index : int);
Returns $match->captures[$index - 1].
cap1
method cap1 : string ();
Returns $match->cap(1).
cap2
method cap2 : string ();
Returns $match->cap(2).
cap3
method cap3 : string ();
Returns $match->cap(3).
cap4
method cap4 : string ();
Returns $match->cap(4).
cap5
method cap5 : string ();
Returns $match->cap(5).
cap6
method cap6 : string ();
Returns $match->cap(6).
cap7
method cap7 : string ();
Returns $match->cap(7).
cap8
method cap8 : string ();
Returns $match->cap(8).
cap9
method cap9 : string ();
Returns $match->cap(9).
cap10
method cap10 : string ();
Returns $match->cap(10).
cap11
method cap11 : string ();
Returns $match->cap(11).
cap12
method cap12 : string ();
Returns $match->cap(12).
cap13
method cap13 : string ();
Returns $match->cap(13).
cap14
method cap14 : string ();
Returns $match->cap(14).
cap15
method cap15 : string ();
Returns $match->cap(15).
cap16
method cap16 : string ();
Returns $match->cap(16).
cap17
method cap17 : string ();
Returns $match->cap(17).
cap18
method cap18 : string ();
Returns $match->cap(18).
cap19
method cap19 : string ();
Returns $match->cap(19).
cap20
method cap20 : string ();
Returns $match->cap(20).
See Also
Copyright & License
Copyright (c) 2023 Yuki Kimoto
MIT License