SPVM::Regex::Match - Regex Matching Result
The Regex::Match class of SPVM has methods to manipulate a regex matching result.
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;
has success : ro byte;
Gets the success field.
success
If a pattern match is successful, this field is set to 1.
has captures : string[];
Gets the captures field.
captures
The captured strings.
method captures : string ($index : int);
The captures method is the method to get an element of the captures field.
The length of the captures field can be got by the "captures_length" method.
has match_start : ro int;
Gets the match_start field.
match_start
The start offset of the matched string.
has match_length : ro int;
Gets the match_length field.
match_length
The length of the matched string.
static method new : Regex::Match ($options = undef : object[]);
Creates a new Regex::Match object.
Options:
The options are key-value pairs.
Each key must be a string type. Otherwise an exception is thrown.
If an unsupported option is specified, an exception is thrown.
Sets the success field.
This option must be cast to a Int object. Otherwise an exception is thrown.
Sets the match_start field.
Sets the match_length field.
Sets the captures field.
A new string array with the same length of this option is created and the address of each string is copied.
This option must be cast to a string[] object. Otherwise an exception is thrown.
Examples:
my $match = Regex::Match->new({success => 1, captures => [(string)"abc", "def"]});
method captures_length : int ();
Gets the length of the "captures" field.
method cap1 : string ();
The same as the "captures" method with 1 as the argument $index.
method cap2 : string ();
The same as the "captures" method with 2 as the argument $index.
method cap3 : string ();
The same as the "captures" method with 3 as the argument $index.
method cap4 : string ();
The same as the "captures" method with 4 as the argument $index.
method cap5 : string ();
The same as the "captures" method with 5 as the argument $index.
method cap6 : string ();
The same as the "captures" method with 6 as the argument $index.
method cap7 : string ();
The same as the "captures" method with 7 as the argument $index.
method cap8 : string ();
The same as the "captures" method with 8 as the argument $index.
method cap9 : string ();
The same as the "captures" method with 9 as the argument $index.
method cap10 : string ();
The same as the "captures" method with 10 as the argument $index.
method cap11 : string ();
The same as the "captures" method with 11 as the argument $index.
method cap12 : string ();
The same as the "captures" method with 12 as the argument $index.
method cap13 : string ();
The same as the "captures" method with 13 as the argument $index.
method cap14 : string ();
The same as the "captures" method with 14 as the argument $index.
method cap15 : string ();
The same as the "captures" method with 15 as the argument $index.
method cap16 : string ();
The same as the "captures" method with 16 as the argument $index.
method cap17 : string ();
The same as the "captures" method with 17 as the argument $index.
method cap18 : string ();
The same as the "captures" method with 18 as the argument $index.
method cap19 : string ();
The same as the "captures" method with 19 as the argument $index.
method cap20 : string ();
The same as the "captures" method with 20 as the argument $index.
Copyright (c) 2023 Yuki Kimoto
MIT License
To install SPVM::Regex, copy and paste the appropriate command in to your terminal.
cpanm
cpanm SPVM::Regex
CPAN shell
perl -MCPAN -e shell install SPVM::Regex
For more information on module installation, please visit the detailed CPAN module installation guide.