Konabob has asked for the wisdom of the Perl Monks concerning the following question:
In the following code, I am inserting 2 tab characters \t\t after every instance where a 2 digit number in a long string is preceded by 2 spaces and followed by a space.
I am using substitution, but wonder if there is a simple one-liner that will add the \t\t for any number between 10 and 99.
$all =~ s/ 95 / 95\t\t/g; $all =~ s/ 80 / 80\t\t/g; $all =~ s/ 75 / 75\t\t/g; $all =~ s/ 70 / 70\t\t/g; $all =~ s/ 65 / 65\t\t/g; $all =~ s/ 60 / 60\t\t/g; $all =~ s/ 50 / 50\t\t/g; $all =~ s/ 40 / 40\t\t/g; $all =~ s/ 33 / 33\t\t/g;
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: simplifying substitution
by swl (Prior) on Mar 08, 2021 at 07:13 UTC | |
by Polyglot (Chaplain) on Mar 08, 2021 at 13:00 UTC | |
by choroba (Cardinal) on Mar 08, 2021 at 13:06 UTC | |
by Polyglot (Chaplain) on Mar 08, 2021 at 14:18 UTC | |
by choroba (Cardinal) on Mar 08, 2021 at 14:23 UTC | |
| |
by Konabob (Initiate) on Mar 08, 2021 at 15:36 UTC | |
|
Re: simplifying substitution
by Anonymous Monk on Mar 08, 2021 at 15:19 UTC |