in reply to masking SSN to last four
Another possible approach to doing what you request:
$ # Code (1-liner, expanded) and example output, $ # handles both '###-##-####' and '#########' formats $ perl -le ' my @c = qw/ 123-45-6789 123456789 / ; foreach my $d ( @c ) { my $e = $d; $e =~ s/^(\d+)(-?)(\d+)(-?)(\d{4})$/ q{#} x length($1) . $2 . q{#} x length($3) . $4 . $5/egimsx; print $e; }' ###-##-6789 #####6789
Hope that helps.
|
---|
Replies are listed 'Best First'. | |
---|---|
Re^2: masking SSN to last four
by Anonymous Monk on Aug 09, 2019 at 01:30 UTC |
In Section
Seekers of Perl Wisdom