Venus::Replace

Replace Class

Replace Class for Perl 5

method: captures method: count method: evaluate method: explain method: get method: initial method: last_match_end method: last_match_start method: matched method: named_captures method: new method: prematched method: postmatched method: set

package main;

use Venus::Replace;

my $replace = Venus::Replace->new(
  string => 'hello world',
  regexp => '(world)',
  substr => 'universe',
);

# $replace->captures;

This package provides methods for manipulating regexp replacement data.

Venus::Kind::Utility

Venus::Role::Encaseable Venus::Role::Explainable

flags: rw, opt, Str, '' regexp: rw, opt, Regexp, qr// string: rw, opt, Str, '' substr: rw, opt, Str, ''

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.

captures() (arrayref)

{ since => '0.01', }

=example-1 captures

# given: synopsis;

my $captures = $replace->captures;

# ["world"]

The count method returns the number of match occurrences from the result object which contains information about the results of the regular expression operation.

count() (number)

{ since => '0.01', }

=example-1 count

# given: synopsis;

my $count = $replace->count;

# 1

The evaluate method performs the regular expression operation and returns an arrayref representation of the results.

evaluate() (arrayref)

{ since => '0.01', }

=example-1 evaluate

# given: synopsis;

my $evaluate = $replace->evaluate;

# [
#   "(world)",
#   "hello universe",
#   1,
#   [6, 6],
#   [11, 11],
#   {},
#   "hello world",
# ]

The explain method returns the subject of the regular expression operation and is used in stringification operations.

explain() (string)

{ since => '0.01', }

=example-1 explain

# given: synopsis;

my $explain = $replace->explain;

# "hello universe"

The get method returns the subject of the regular expression operation.

get() (string)

{ since => '0.01', }

=example-1 get

# given: synopsis;

my $get = $replace->get;

# "hello universe"

The initial method returns the unaltered string from the result object which contains information about the results of the regular expression operation.

initial() (string)

{ since => '0.01', }

=example-1 initial

# given: synopsis;

my $initial = $replace->initial;

# "hello world"

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.

last_match_end() (maybe[within[arrayref, number]])

{ since => '0.01', }

=example-1 last_match_end

# given: synopsis;

my $last_match_end = $replace->last_match_end;

# [11, 11]

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.

last_match_start() (maybe[within[arrayref, number]])

{ since => '0.01', }

=example-1 last_match_start

# given: synopsis;

my $last_match_start = $replace->last_match_start;

# [6, 6]

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.

matched() (maybe[string])

{ since => '0.01', }

=example-1 matched

# given: synopsis;

my $matched = $replace->matched;

# "world"

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.

named_captures() (hashref)

{ since => '0.01', }

=example-1 named_captures

# given: synopsis;

my $named_captures = $replace->named_captures;

# {}

The new method constructs an instance of the package.

new(any @args) (Venus::Replace)

{ since => '4.15', }

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.

prematched() (Maybe[string])

{ since => '0.01', }

=example-1 prematched

# given: synopsis;

my $prematched = $replace->prematched;

# "hello "

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.

postmatched() (Maybe[string])

{ since => '0.01', }

=example-1 postmatched

# given: synopsis;

my $postmatched = $replace->postmatched;

# ""

The set method sets the subject of the regular expression operation.

set(string $data) (string)

{ since => '0.01', }

=example-1 set

# given: synopsis;

my $set = $replace->set('hello universe');

# "hello universe"
package main;

use Venus::Replace;

my $replace = Venus::Replace->new(
  string => 'hello world',
  regexp => 'world',
  substr => 'universe',
  flags => 'i',
);

$replace->evaluate;

$replace->flags('q');

$replace->evaluate;

# Error! (on.evaluate)

This package overloads the . operator.

This package overloads the eq operator.

This package overloads the ne operator.

This package overloads the qr operator.

This package overloads the "" operator.

This package overloads the ~~ operator.

t/Venus.t: present: authors t/Venus.t: present: license

70 POD Errors

The following errors were encountered while parsing the POD:

Around line 14:

Unknown directive: =name

Around line 22:

Unknown directive: =tagline

Around line 30:

Unknown directive: =abstract

Around line 38:

Unknown directive: =includes

Around line 59:

Unknown directive: =synopsis

Around line 82:

Unknown directive: =description

Around line 90:

Unknown directive: =inherits

Around line 98:

Unknown directive: =integrates

Around line 107:

Unknown directive: =attributes

Around line 118:

Unknown directive: =method

Around line 124:

Unknown directive: =signature

Around line 128:

Unknown directive: =metadata

Around line 152:

Unknown directive: =method

Around line 158:

Unknown directive: =signature

Around line 162:

Unknown directive: =metadata

Around line 186:

Unknown directive: =method

Around line 191:

Unknown directive: =signature

Around line 195:

Unknown directive: =metadata

Around line 251:

=cut found outside a pod block. Skipping to next block.

Around line 262:

Unknown directive: =method

Around line 267:

Unknown directive: =signature

Around line 271:

Unknown directive: =metadata

Around line 295:

Unknown directive: =method

Around line 299:

Unknown directive: =signature

Around line 303:

Unknown directive: =metadata

Around line 327:

Unknown directive: =method

Around line 332:

Unknown directive: =signature

Around line 336:

Unknown directive: =metadata

Around line 360:

Unknown directive: =method

Around line 366:

Unknown directive: =signature

Around line 370:

Unknown directive: =metadata

Around line 394:

Unknown directive: =method

Around line 400:

Unknown directive: =signature

Around line 404:

Unknown directive: =metadata

Around line 428:

Unknown directive: =method

Around line 434:

Unknown directive: =signature

Around line 438:

Unknown directive: =metadata

Around line 462:

Unknown directive: =method

Around line 468:

Unknown directive: =signature

Around line 472:

Unknown directive: =metadata

Around line 512:

=cut found outside a pod block. Skipping to next block.

Around line 522:

Unknown directive: =method

Around line 526:

Unknown directive: =signature

Around line 530:

Unknown directive: =metadata

Around line 548:

=cut found outside a pod block. Skipping to next block.

Around line 572:

=cut found outside a pod block. Skipping to next block.

Around line 585:

Unknown directive: =method

Around line 591:

Unknown directive: =signature

Around line 595:

Unknown directive: =metadata

Around line 619:

Unknown directive: =method

Around line 625:

Unknown directive: =signature

Around line 629:

Unknown directive: =metadata

Around line 653:

Unknown directive: =method

Around line 657:

Unknown directive: =signature

Around line 661:

Unknown directive: =metadata

Around line 685:

Unknown directive: =raise

Around line 716:

Unknown directive: =operator

Around line 732:

=cut found outside a pod block. Skipping to next block.

Around line 742:

Unknown directive: =operator

Around line 758:

=cut found outside a pod block. Skipping to next block.

Around line 768:

Unknown directive: =operator

Around line 784:

=cut found outside a pod block. Skipping to next block.

Around line 794:

Unknown directive: =operator

Around line 810:

=cut found outside a pod block. Skipping to next block.

Around line 820:

Unknown directive: =operator

Around line 836:

=cut found outside a pod block. Skipping to next block.

Around line 854:

=cut found outside a pod block. Skipping to next block.

Around line 864:

Unknown directive: =operator

Around line 880:

=cut found outside a pod block. Skipping to next block.

Around line 886:

Unknown directive: =partials