Skip to Main Content

SQL & PL/SQL

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

Mask the numbers

dbuserMar 26 2012 — edited Mar 26 2012
Hi,

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
This post has been answered by jeneesh on Mar 26 2012
Jump to Answer
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Apr 23 2012
Added on Mar 26 2012
8 comments
924 views