There is an ongoing outage on the primary CPAN mirror. It is possible to work around the issue by using MetaCPAN as a mirror.

Name

SPVM::Regex::Replacer - Callback for Regex Replacement

Description

Regex::Replacer interface in SPVM is a callback for a regex replacement.

Usage

use Regex::Replacer;
use Regex;

my $replacer = (Regex::Replacer)method : string ($re : Regex, $match : Regex::Match) {
  my $replace = "AB" . $match->cap1 . "C";
  return $replace;
});

my $string = "abc";
my $re = Regex->new("ab(c)");
$re->replace_g(my $_ = [$string], $replacer);

Interface Methods

required method : string ($re : Regex, $match : Regex::Match);

This method is meant to return a replacement string.

Copyright & License

Copyright (c) 2023 Yuki Kimoto

MIT License