in reply to Re^2: regex in REPLACEMENT in s///
in thread regex in REPLACEMENT in s///

I probably would have gone for

$res = $str =~ s{ \d+ }{ $& =~ tr//3/cr }xer;

or

$res = $str =~ s{ \d+ }{ 3 x length $& }xer;

TMTOWTDI gone wild :)

Replies are listed 'Best First'.
Re^4: regex in REPLACEMENT in s///
by ikegami (Patriarch) on Sep 14, 2023 at 12:41 UTC

    Well, I saw it as an exercise in using a nested s///. If you don't, then you might as well use:

    my $res = $str =~ s/\d/3/gr;

      He actually says he wanted 333333.56 and not 333333.33, so nope...