Beefy Boxes and Bandwidth Generously Provided by pair Networks
XP is just a number
 
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 lurking in the Monastery: (3)
As of 2025-12-10 14:51 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    What's your view on AI coding assistants?





    Results (91 votes). Check out past polls.

    Notices?
    hippoepoptai's answer Re: how do I set a cookie and redirect was blessed by hippo!
    erzuuliAnonymous Monks are no longer allowed to use Super Search, due to an excessive use of this resource by robots.