Mask the numbers
dbuserMar 26 2012 — edited Mar 26 2012Hi,
I am using Oracle 10 g.
I have a column of credit card numbers and i wanted the numbers to be masked. I want the first 6 numbers to be remain as it is along with last 4 numbers . The data between first 6 digit and last 4 digit should be replaced with xxxx
for example
5454008812345555
would become
545400xxxxxx5555
The length of credit card number can be any length but in all the cases it should only replace the value between first 6 digit and last 4 digit should be replaced with xxxx
I can use the below mention query, if I am sure that the length of the column value will remain constant, however that not the scenario here
SELECT REGEXP_REPLACE('123413-241-234-1234',
'([[:digit:]]{6})\-([[:digit:]]{3})\-([[:digit:]]{3})\-([[:digit:]]{4})',
'\1-xxx-xxx-\4'
)
FROM dual;
Regards
Edited by: sandm on Mar 26, 2012 12:01 AM