Regular Expressions 101

Community Patterns

Community Library Entry

1

Regular Expression
Created·2024-10-14 20:03
Updated·2024-10-16 18:23
Flavor·JavaScript

/
(^4(?:\d?){3}\s?(?:\d?){4}\s?(?:\d?){4}(?:\s?\d?){7}$)|(^(?:5[1-5](?:\d?){2}\s?|222\d?\s?|22[3-9]\d?\s?|2[3-6](?:\d?){2}\s?|27[01]\d?\s?|2720\s?)(?:(?:\d?){4}\s?){2}(?:\d?){4}$)|(^3[47](?:\d?){2}\s?(?:(?:\d?){4}\s?(?:\d?){2}\s?(?:\d?){2}\s?)(?:\d?){3}$)|(^3(?:0[0-5]|[68]\d?)\d?\s?(?:(?:\d?){4}\s?(?:\d?){2}\s?(?:\d?){2}\s?)(?:\s?\d?){7}$)|(^6(?:011\s?|5(?:\d?){2}\s?)(?:(?:\d?){4}\s?){3}(?:\d?\s?){3}$)|(^(?:2131\s?|1800\s?|35(?:\d?){2}\s?\d?\s?)(?:\d?\s?){14}$)
/
gm
Open regex in editor

Description

Credit Card Carrier Prediction

This regex is specifically designed to predict from the first few characters which carrier type the credit card number is.

Submitted by anonymous