Beefy Boxes and Bandwidth Generously Provided by pair Networks
"be consistent"
 
PerlMonks  

Re: masking SSN to last four

by atcroft (Abbot)
on Aug 09, 2019 at 01:03 UTC ( #11104206=note: print w/replies, xml ) Need Help??


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

    Thank You works Perfectly!

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://11104206]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others examining the Monastery: (3)
As of 2020-09-23 07:16 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    If at first I donít succeed, I Ö










    Results (130 votes). Check out past polls.

    Notices?