Operating System - HP-UX
1752782 Members
6628 Online
108789 Solutions
New Discussion

Re: sed - masking credit card numbers

 
SOLVED
Go to solution
FAZILUDDIN
Occasional Visitor

Re: sed - masking credit card numbers

Please assist me in regex to mask middle 8 digits of 16 digits card number in linux? Any one can help on this will be appreciated.

Dennis Handly
Acclaimed Contributor

Re: sed - masking credit card numbers

@FAZILUDDIN> regex to mask middle 8 digits of 16 digits card number

Assuming you have already extracted the number or only strings with >= 16 digits are credit card numbers.

This is similar to my reply to:

https://community.hpe.com/t5/Languages-and-Scripting/sed-masking-credit-card-numbers/m-p/7020320#U4303596

sed -e 's/\([0-9]\{4\}\)[0-9]\{8\}\([0-9]\{4\}\)/\1********\2/' file

Keeps first and last 4.  Replaces middle 8 by "*".