in reply to replace number by args<number>
An alternative to using a regular expression with a capture of a digit and subsequent replacment with args$1 would be to use a zero-width look-ahead, effectively inserting "args" at any point followed by a digit.
use strict; use warnings; my @inputs = ( q{A) 1:2}, q{B) -p 1 -t 2 3}, q{C) 1 2}, q{D) 12}, ); my @outputs = map { s{(?=\d)}{args}g; $_ } @inputs; print qq{$_\n} for @outputs;
The output.
A) args1:args2 B) -p args1 -t args2 args3 C) args1 args2 D) args1args2
I hope this is useful.
Cheers,
JohnGG
|
|---|