NAME
Venus::Replace - Replace Class
ABSTRACT
Replace Class for Perl 5
SYNOPSIS
package main;
use Venus::Replace;
my $replace = Venus::Replace->new(
string => 'hello world',
regexp => '(world)',
substr => 'universe',
);
# $replace->captures;
DESCRIPTION
This package provides methods for manipulating regexp replacement data.
ATTRIBUTES
This package has the following attributes:
flags
flags(Str)
This attribute is read-write, accepts (Str)
values, is optional, and defaults to ''
.
regexp
regexp(Regexp)
This attribute is read-write, accepts (Regexp)
values, is optional, and defaults to qr//
.
string
string(Str)
This attribute is read-write, accepts (Str)
values, is optional, and defaults to ''
.
substr
substr(Str)
This attribute is read-write, accepts (Str)
values, is optional, and defaults to ''
.
INHERITS
This package inherits behaviors from:
INTEGRATES
This package integrates behaviors from:
METHODS
This package provides the following methods:
captures
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
count
count() (Num)
The count method returns the number of match occurrences from the result object which contains information about the results of the regular expression operation.
Since 0.01
evaluate
evaluate() (ArrayRef)
The evaluate method performs the regular expression operation and returns an arrayref representation of the results.
Since 0.01
- evaluate example 1
-
# given: synopsis; my $evaluate = $replace->evaluate; # [ # "(world)", # "hello universe", # 1, # [6, 6], # [11, 11], # {}, # "hello world", # ]
- evaluate example 2
-
package main; use Venus::Replace; my $replace = Venus::Replace->new( string => 'hello world', regexp => 'world)(', substr => 'universe', ); my $evaluate = $replace->evaluate; # Exception! Venus::Replace::Error (isa Venus::Error)
explain
explain() (Str)
The explain method returns the subject of the regular expression operation and is used in stringification operations.
Since 0.01
get
get() (Str)
The get method returns the subject of the regular expression operation.
Since 0.01
initial
initial() (Str)
The initial method returns the unaltered string from the result object which contains information about the results of the regular expression operation.
Since 0.01
last_match_end
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.
Since 0.01
- last_match_end example 1
-
# given: synopsis; my $last_match_end = $replace->last_match_end; # [11, 11]
last_match_start
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.
Since 0.01
- last_match_start example 1
-
# given: synopsis; my $last_match_start = $replace->last_match_start; # [6, 6]
matched
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.
Since 0.01
named_captures
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.
Since 0.01
- named_captures example 2
-
package main; use Venus::Replace; my $replace = Venus::Replace->new( string => 'hello world', regexp => '(?<locale>world)', substr => 'universe', ); my $named_captures = $replace->named_captures; # { locale => ["world"] }
postmatched
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.
Since 0.01
prematched
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.
Since 0.01
set
set(Str $data) (Str)
The set method sets the subject of the regular expression operation.
Since 0.01
OPERATORS
This package overloads the following operators:
- operation:
(.)
-
This package overloads the
.
operator.example 1
# given: synopsis; my $result = $replace . ', welcome'; # "hello universe, welcome"
- operation:
(eq)
-
This package overloads the
eq
operator.example 1
# given: synopsis; my $result = $replace eq 'hello universe'; # 1
- operation:
(ne)
-
This package overloads the
ne
operator.example 1
# given: synopsis; my $result = $replace ne 'Hello universe'; # 1
- operation:
(qr)
-
This package overloads the
qr
operator.example 1
# given: synopsis; my $result = 'hello universe, welcome' =~ qr/$replace/; # 1