Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl Monk, Perl Meditation
 
PerlMonks  

Re: masking SSN to last four

by atcroft (Abbot)
on Aug 09, 2019 at 01:03 UTC ( [id://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
Domain Nodelet?
Node Status?
node history
Node Type: note [id://11104206]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others meditating upon the Monastery: (4)
As of 2024-03-29 07:54 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found