Regular Expressions 101

Community Patterns

Community Library Entry

1

Regular Expression
ECMAScript (JavaScript)

/
(?:%?B[3-5][0-9]{14,15}\^[a-zA-Z0-9 \/]{2,26}\^(2|3)[0-9](01|02|03|04|05|06|07|08|09|10|11|12)[0-9 ]{6,34}\??)
/
gm

Description

Captures group that is either AMEX, MC, or Visa with or without start and end sentinels including discretionary data after section for name

Does not support 13 digit credit cards, as they are not used anymore. Only allows for 15 digit AMEX and 16 digit Visa or MC

Submitted by BigDad - 3 years ago