kepler has asked for the wisdom of the Perl Monks concerning the following question:
I'm replacing a pattern in a string like $data =~ s/(nr\d+)/calc\($1\);/gi;
I get pairs like "calc(nr45);". Next I want to replace only the remaining characters in the string like $data =~ s/(\d+)/$1*4/ge but without modifying the first ones. So if the string is "hello nr34 , 56, hi" I want to get "calc(nr34);" and modify "56" to 56*4... Is there a straight way to do this?Thanks
Kepler
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: String substitution
by Marshall (Canon) on Sep 20, 2016 at 01:56 UTC | |
by AnomalousMonk (Archbishop) on Sep 20, 2016 at 02:56 UTC | |
|
Re: String substitution
by AnomalousMonk (Archbishop) on Sep 20, 2016 at 02:33 UTC | |
|
Re: String substitution
by kroach (Pilgrim) on Sep 20, 2016 at 15:15 UTC | |
|
Re: String substitution
by Anonymous Monk on Sep 20, 2016 at 03:36 UTC |