Venus::Search - Search Class
Search Class for Perl 5
package main; use Venus::Search; my $search = Venus::Search->new( string => 'hello world', regexp => '(hello)', ); # $search->captures;
This package provides methods for manipulating regexp search data.
This package has the following attributes:
flags(Str)
This attribute is read-write, accepts (Str) values, is optional, and defaults to ''.
(Str)
''
regexp(Regexp)
This attribute is read-write, accepts (Regexp) values, is optional, and defaults to qr//.
(Regexp)
qr//
string(Str)
This package inherits behaviors from:
Venus::Kind::Utility
This package integrates behaviors from:
Venus::Role::Explainable
Venus::Role::Stashable
This package provides the following methods:
captures() (ArrayRef)
The captures method returns the capture groups from the result object which contains information about the results of the regular expression operation. This method can return a list of values in list-context.
Since 0.01
0.01
# given: synopsis; my $captures = $search->captures; # ["hello"]
count() (Num)
The count method returns the number of matches found in the result object which contains information about the results of the regular expression operation.
# given: synopsis; my $count = $search->count; # 1
evaluate() (ArrayRef)
The evaluate method performs the regular expression operation and returns an arrayref representation of the results.
# given: synopsis; my $evaluate = $search->evaluate; # ["(hello)", "hello world", 1, [0, 0], [5, 5], {}, "hello world"]
package main; use Venus::Search; my $search = Venus::Search->new( string => 'hello world', regexp => 'hello:)', ); my $evaluate = $search->evaluate; # Exception! Venus::Search::Error (isa Venus::Error)
explain() (Str)
The explain method returns the subject of the regular expression operation and is used in stringification operations.
# given: synopsis; my $explain = $search->explain; # "hello world"
get() (Str)
The get method returns the subject of the regular expression operation.
# given: synopsis; my $get = $search->get; # "hello world"
initial() (Str)
The initial method returns the unaltered string from the result object which contains information about the results of the regular expression operation.
# given: synopsis; my $initial = $search->initial; # "hello world"
last_match_end() (Maybe[ArrayRef[Int]])
The last_match_end method returns an array of offset positions into the string where the capture(s) stopped matching from the result object which contains information about the results of the regular expression operation.
# given: synopsis; my $last_match_end = $search->last_match_end; # [5, 5]
last_match_start() (Maybe[ArrayRef[Int]])
The last_match_start method returns an array of offset positions into the string where the capture(s) matched from the result object which contains information about the results of the regular expression operation.
# given: synopsis; my $last_match_start = $search->last_match_start; # [0, 0]
matched() (Maybe[Str])
The matched method returns the portion of the string that matched from the result object which contains information about the results of the regular expression operation.
# given: synopsis; my $matched = $search->matched; # "hello"
named_captures() (HashRef)
The named_captures method returns a hash containing the requested named regular expressions and captured string pairs from the result object which contains information about the results of the regular expression operation.
# given: synopsis; my $named_captures = $search->named_captures; # {}
package main; use Venus::Search; my $search = Venus::Search->new( string => 'hello world', regexp => '(?<locale>world)', ); my $named_captures = $search->named_captures; # { locale => ["world"] }
postmatched() (Maybe[Str])
The postmatched method returns the portion of the string after the regular expression matched from the result object which contains information about the results of the regular expression operation.
# given: synopsis; my $postmatched = $search->postmatched; # " world"
prematched() (Maybe[Str])
The prematched method returns the portion of the string before the regular expression matched from the result object which contains information about the results of the regular expression operation.
# given: synopsis; my $prematched = $search->prematched; # ""
set(Str $string) (Str)
The set method sets the subject of the regular expression operation.
# given: synopsis; my $set = $search->set('hello universe'); # "hello universe"
This package overloads the following operators:
(.)
This package overloads the . operator.
.
example 1
# given: synopsis; my $result = $search . ', welcome'; # "hello world, welcome"
(eq)
This package overloads the eq operator.
eq
# given: synopsis; my $result = $search eq 'hello world'; # 1
(ne)
This package overloads the ne operator.
ne
# given: synopsis; my $result = $search ne 'Hello world'; # 1
(qr)
This package overloads the qr operator.
qr
# given: synopsis; my $result = 'hello world, welcome' =~ qr/$search/; # 1
("")
This package overloads the "" operator.
""
# given: synopsis; my $result = "$search"; # "hello world"
example 2
# given: synopsis; my $result = "$search, $search"; # "hello world, hello world"
(~~)
This package overloads the ~~ operator.
~~
# given: synopsis; my $result = $search ~~ 'hello world'; # 1
To install Venus, copy and paste the appropriate command in to your terminal.
cpanm
cpanm Venus
CPAN shell
perl -MCPAN -e shell install Venus
For more information on module installation, please visit the detailed CPAN module installation guide.