Here is my scalar:
my $var = "foo1";
and here is what I tried to do:
$var =~ s/[0-9]/_[0-9]/;
Result:
foo_[0-9]
Expected Result:
foo_1
It would be great if you could answer for finding foo and adding the underscore after the match, and also finding 1 and adding the underscore before.
$var = s/foo/something/
and
$var = s/[0-9]/something/
Thanks in advance
Capture what you want to insert, then insert what you captured:
Or use a lookahead:
As requested, solutions that also match
foo:Note that captures slow down the match.