Regular Expressions 101

Community Patterns

1...45678...901

Community Library Entry

4

Regular Expression
PCRE (PHP <7.3)

/
(^5[1-5]|^4|^3[47])|(^6011|65|64[4-9]|622(1(2[6-9]|[3-9]\d)|[2-8]\d{2}|9([01]\d|2[0-5])))\d+
/
g

Description

MasterCard - ^5[1-5]\d+ Visa - ^4\d+ Amex - ^3[47]\d+ Discover - 6011|65|64...

Submitted by Eric Foster - 8 years ago