Replacing Credit Card Numbers

Posted by Del on Stack Overflow See other posts from Stack Overflow or by Del
Published on 2010-06-08T07:33:02Z Indexed on 2010/06/08 8:02 UTC
Read the original article Hit count: 479

Filed under:

Hi,

I'm using an sql to replace credit card numbers with xxxx and finding that REGEX_REPLACE does not consistently replace everything. Below is the SET command i'm using on the SQL

SET COMMENTS_LONG = 
    REGEXP_REPLACE (COMMENTS_LONG,'\D[1-6]\d{3}.\d{4}.\d{4}.\d{3}(\d{1}.\d{3})?|\D[1-6]\d{12,15}|\D[1-6]\d{3}.\d{3}.?\d{3}.\d{5}', ' XXXXXXXXXXXXXXXX') 

Before

Elizabeth aclled to change address.5430-6000-2111-1931 A

After

Elizabeth aclled to change address XXXXXXXXXXXXXXXX1 A

I tried increasing the number of X but result is the same. I also find that i have to put a space in front of the first X as it appears to move 1 char to the left.

© Stack Overflow or respective owner

Related posts about regex