Name
SPVM::Regex::Replacer - Interface for Regex Replacement Callback
Description
The Regex::Replacer interface of SPVM has an interface method for the regex replacement callback.
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)"
);
my
$replaced_string
=
$re
->replace_g(
$string
,
$replacer
);
Interface Methods
required method : string (
$re
: Regex,
$match
: Regex::Match =
undef
);
Receives a Regex object and a Regex::Match object, and returns a replacement string.
The $match argument will be required in the future release.
Copyright & License
Copyright (c) 2023 Yuki Kimoto
MIT License