Regex to Detect Credit Card Data

Credit Card data is normally masked with *. But the problem is how to detect in side a block of text. If you are using PHP then you can use this Regex

/(?:\d[ -]*?){13,16}/

to detect any of the credit card format

16 digit:

#### #### #### ####

####-####-####-####

################

15 digit:

#### #### #### ###

####-####-####-###

###############

#### ###### #####

####-######-#####

In case of JS the same work just remove the forward slashes.

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s