NAME
Venus::Regexp - Regexp Class
ABSTRACT
Regexp Class for Perl 5
SYNOPSIS
package main;
use Venus::Regexp;
my $regexp = Venus::Regexp->new(
qr/(?<greet>\w+) (?<username>\w+)/,
);
# $regexp->search;
DESCRIPTION
This package provides methods for manipulating regexp data.
INHERITS
This package inherits behaviors from:
METHODS
This package provides the following methods:
default
default() (Regexp)
The default method returns the default value, i.e. qr//
.
Since 0.01
replace
replace(Str $string, Str $substr, Str $flags) (Replace)
The replace method performs a regular expression substitution on the given string. The first argument is the string to match against. The second argument is the replacement string. The optional third argument might be a string representing flags to append to the s///x operator, such as 'g' or 'e'. This method will always return a Venus::Replace object which can be used to introspect the result of the operation.
Since 0.01
- replace example 1
-
package main; use Venus::Regexp; my $regexp = Venus::Regexp->new( qr/(?<username>\w+)$/, ); my $replace = $regexp->replace('Hey, unknown', 'cpanery'); # bless({ ... }, 'Venus::Replace')
search
search(Str $string) (Search)
The search method performs a regular expression match against the given string, this method will always return a Venus::Search object which can be used to introspect the result of the operation.
Since 0.01
- search example 1
-
package main; use Venus::Regexp; my $regexp = Venus::Regexp->new( qr/(?<greet>\w+), (?<username>\w+)/, ); my $search = $regexp->search('hey, cpanery'); # bless({ ... }, 'Venus::Search')
OPERATORS
This package overloads the following operators:
- operation:
(eq)
-
This package overloads the
eq
operator.example 1
# given: synopsis; my $result = $regexp eq '(?^u:(?<greet>\\w+) (?<username>\\w+))'; # 1
- operation:
(ne)
-
This package overloads the
ne
operator.example 1
# given: synopsis; my $result = $regexp ne '(?<greet>\w+) (?<username>\w+)'; # 1
- operation:
(qr)
-
This package overloads the
qr
operator.example 1
# given: synopsis; my $result = 'Hello Friend' =~ $regexp; # 1
AUTHORS
Cpanery, cpanery@cpan.org
LICENSE
Copyright (C) 2021, Cpanery
Read the "license" file.