in reply to Re: regex in REPLACEMENT in s///
in thread regex in REPLACEMENT in s///
Aye, /r (introduced in 5.14) is key here.
You can use /r on the s/// too.
And we don't need those captures.my $res = $str =~ s{ (\d+) }{ $1 =~ s/(\d)/3/gr }xer;
my $res = $str =~ s{ \d+ }{ $& =~ s/\d/3/gr }xer;
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^3: regex in REPLACEMENT in s///
by tybalt89 (Monsignor) on Sep 12, 2023 at 23:21 UTC | |
by ikegami (Patriarch) on Sep 14, 2023 at 12:41 UTC | |
by tybalt89 (Monsignor) on Sep 14, 2023 at 12:52 UTC |