본문 바로가기
IT 일반 정보

신용카드 번호 정규표현식으로 패턴 만들기

by 떠도리c 2024. 8. 29.
반응형

정규표현식으로 신용카드 번호 패턴 만들기

 

 

BC, Visa, MasterCard, Discover, Amex, Diners Club, JCB

^(?:(94[0-9]{14})|(4[0-9]{12}(?:[0-9]{3})?)|(5[1-5][0-9]{14})|(6(?:011|5[0-9]{2})[0-9]{12})|(3[47][0-9]{13})|(3(?:0[0-5]|[68][0-9])[0-9]{11})|((?:2131|1800|35[0-9]{3})[0-9]{11}))$

 

Visa, MasterCard, Discover, Amex, Diners Club/Carte Blanche

^(?:(?<Visa>4\d{3})|(?<Mastercard>5[1-5]\d{2})|(?<Discover>6011)|(?<DinersClub>(?:3[68]\d{2})|(?:30[0-5]\d))|(?<AmericanExpress>3[47]\d{2}))([ -]?)(?(DinersClub)(?:\d{6}\1\d{4})|(?(AmericanExpress)(?:\d{6}\1\d{5})|(?:\d{4}\1\d{4}\1\d{4})))$

 

Visa

^([4]{1})([0-9]{12,15})$

4\d{12}(?:\d{3})?

 

Master

^([51|52|53|54|55]{2})([0-9]{14})$
5[12345]\d{14}
^5[1-5][0-9]{14}$
^5[1-5]\d{14}$


^((5[1-5])([0-9]{2})((-|\s)?[0-9]{4}){3})$

 

discover

^([6011]{4})([0-9]{12})$
6(?:011|5\d{2})\d{12}
(^(6011)\d{12}$)|(^(65)\d{14}$)



^((6011)((-|\s)?[0-9]{4}){3})$

 

Diners Club

^([30|36|38]{2})([0-9]{12})$

3(?:0[012345]|[68]\d)\d{11}

 

Switch, Solo, Visa, MasterCard 및 Discover

^((67\d{2})|(4\d{3})|(5[1-5]\d{2})|(6011))-?\s?\d{4}-?\s?\d{4}-?\s?\d{4}|3[4,7]\d{13}$

 

MC, Visa, Amex, Diners/CarteBlanche, Discover/Novus, Enroute , JCB

^3(?:[47]\d([ -]?)\d{4}(?:\1\d{4}){2}|0[0-5]\d{11}|[68]\d{12})$|^4(?:\d\d\d)?([ -]?)\d{4}(?:\2\d{4}){2}$|^6011([ -]?)\d{4}(?:\3\d{4}){2}$|^5[1-5]\d\d([ -]?)\d{4}(?:\4\d{4}){2}$|^2014\d{11}$|^2149\d{11}$|^2131\d{11}$|^1800\d{11}$|^3\d{15}$

 

Visa CC, Visa ATM 전용, Visa Electron 및 Visa Delta

13 또는 16 자리 번호와 일치

(^4\d{12}$)|(^4[0-8]\d{14}$)|(^(49)[^013]\d{13}$)|(^(49030)[0-1]\d{10}$)|(^(49033)[0-4]\d{10}$)|(^(49110)[^12]\d{10}$)|(^(49117)[0-3]\d{10}$)|(^(49118)[^0-2]\d{10}$)|(^(493)[^6]\d{12}$)

 

Meastro

(^(5[0678])\d{11,18}$) |(^(6[^0357])\d{11,18}$) |(^(601)[^1]\d{9,16}$) |(^(6011)\d{9,11}$) |(^(6011)\d{13,16}$) |(^(65)\d{11,13}$) |(^(65)\d{15,18}$) |(^(633)^34) |(^(6333)0-4) |(^(6333)0-4) |(^(6333)0-4) |(^(6333)5-9) |(^(6333)5-9) |(^(6333)5-9) |(^(6334)0-4) |(^(6334)0-4) |(^(6334)0-4) |(^(67)^(59)) |(^(6759)](\d{9,11}$)) |(^(6759)](\d{13}$)) |(^(6759)](\d{16}$)) |(^(67)^(67)) |(^(6767)](\d{9,11}$)) |(^(6767)](\d{13}$)) |(^(6767)](\d{16}$))

 

Amex

(^3[47])((\d{11}$)|(\d{13}$))


3[47]\d{13}

 

Solo

(^(6334)5-9) |(^(6767)(\d{12}$|\d{14,15}$))

 

Switch

(\d{6}[-\s]?\d{12})|(\d{4}[-\s]?\d{4}[-\s]?\d{4}[-\s]?\d{4})

 

Switch CC

(^(49030)2-9) |(^(49033)5-9) |(^(49110)1-2) |(^(49117)4-9) |(^(49118)0-2) |(^(4936)(\d{12}$|\d{14,15}$)) |(^(564182)(\d{11}$|\d{13,14}$)) |(^(6333)0-4) |(^(6759)(\d{12}$|\d{14,15}$))

^([0-9]{6}[\s\-]{1}[0-9]{12}|[0-9]{18})$

 

Dinner CC

(^(30)[0-5]\d{11}$)|(^(36)\d{12}$)|(^(38[0-8])\d{11}$)

 

Cart Blance

^(389)[0-9]{11}$

 

EnRoute 카드

(^(2014)|^(2149))\d{11}$

 

UK Debit 카드

Solo, Switch 또는 Maestro 에 매치됩니다.

(^(5[0678])\d{11,18}$)|(^(6[^05])\d{11,18}$)|(^(601)[^1]\d{9,16}$)|(^(6011)\d{9,11}$)|(^(6011)\d{13,16}$)|(^(65)\d{11,13}$)|(^(65)\d{15,18}$)|(^(49030)2-9)|(^(49033)5-9)|(^(49110)1-2)|(^(49117)4-9)|(^(49118)0-2)|(^(4936)(\d{12}$|\d{14,15}$))

 

JCB 카드

(^(352)8-9)|(^(35)3-8)

(?:2131|1800|35\d{3})\d{11}

 

Switch, Solo, Visa, MasterCard, Amex 및 Discover

^((67\d{2})|(4\d{3})|(5[1-5]\d{2})|(6011))(-?\s?\d{4}){3}|(3[4,7])\d{2}-?\s?\d{6}-?\s?\d{5}$

 

Amex, Visa, MasterCard

^((4\d{3})|(5[1-5]\d{2}))(-?|\040?)(\d{4}(-?|\040?)){3}|^(3[4,7]\d{2})(-?|\040?)\d{6}(-?|\040?)\d{5}

 

Visa, MasterCard, Discover, Amex

^((4\d{3})|(5[1-5]\d{2})|(6011))-?\d{4}-?\d{4}-?\d{4}|3[4,7]\d{13}$

 

Amex, Visa, Master, Dinnerclub, JCB, enRoute, Discover

(4\d{12})|(((4|3)\d{3})|(5[1-5]\d{2})|(6011))(-?|\040?)(\d{4}(-?|\040?)){3}|((3[4,7]\d{2})((-?|\040?)\d{6}(-?|\040?)\d{5}))|(3[4,7]\d{2})((-?|\040?)\d{4}(-?|\040?)\d{4}(-?|\040?)\d{3})|(3[4,7]\d{1})(-?|\040?)(\d{4}(-?|\040?)){3}|(30[0-5]\d{1}|(36|38)\d(2))((-?|\040?)\d{4}(-?|\040?)\d{4}(-?|\040?)\d{2})|((2131|1800)|(2014|2149))((-?|\040?)\d{4}(-?|\040?)\d{4}(-?|\040?)\d{3})


^3|4|5|6

 

Visa 및 MasterCard

^(5[1-5]\d{2})\d{12}|(4\d{3})(\d{12}|\d{9})$

 

Visa, Amex, Discover 및 Mastercard

^((4(\d{12}|\d{15}))|(5\d{15})|(6011\d{12})|(3(4|7)\d{13}))$

 

identity

^((11|12|13|14|15|21|22|23|31|32|33|34|35|36|37|41|42|43|44|45|46|50|51|52|53|54|61|62|63|64|65|71|81|82|91)\d{4})((((((19|20)(([02468][048])|([13579][26]))0229))|((20[0-9][0-9])|(19[0-9][0-9]))((((0[1-9])|(1[0-2]))((0[1-9])|(1\d)|(2[0-8])))|((((0[1,3-9])|(1[0-2]))(29|30))|(((0[13578])|(1[02]))31))))((\d{3}(x|X))|(\d{4})))|((((([02468][048])|([13579][26]))0229)|(\d{2}((((0[1-9])|(1[0-2]))((0[1-9])|(1\d)|(2[0-8])))|(((0[1,3-9])|(1[0-2]))(29|30))|(((0[13578])|(1[02]))31))))\d{3}))$

 

UnionPay 카드

62[0-9]{14,17}

 

신용카드 만료 날짜 검증

신용 카드 만료 날짜를 확인하기 위해 MM/YY 형식을 검증합니다.

^((0[1-9])|(1[0-2]))\/(\d{2})$
반응형