You could also use look-behind and look-ahead assertions to find the point in the string where the initial letters end insert the required number of 'X's using a regex substitution using the 'e' modifier.
knoppix@Microknoppix:~$ perl -E ' > @accts = qw{ > CAL2345-06 > CALI123456-09 > FLOR1234567-01 > MEGA9988776655-43 > }; > say for > map { > s{ (?<=[a-zA-Z]) (?![a-zA-Z]) }{ q{X} x ( 14 - length ) }xe; > $_; > } > @accts;' CALXXXX2345-06 CALIX123456-09 FLOR1234567-01 MEGA9988776655-43 knoppix@Microknoppix:~$
I hope this is helpful.
Cheers,
JohnGG
In reply to Re: Counting to add space to a string
by johngg
in thread Counting to add space to a string
by Anonymous Monk
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |