Regular Expressions 101

Community Patterns

Credit Card Validator

0

Regular Expression
PCRE (PHP <7.3)

/
^(?:4[0-9]{12}(?:[0-9]{3})?|5[1-5][0-9]{14}|6(?:011|5[0-9][0-9])[0-9]{12}|3[47][0-9]{13})$
/
gm

Description

For Visa, Mastercard, Discover, and AMEX

Submitted by David Avellan - 8 years ago