Please enable JavaScript to use regex101
/
^
r
e
g
e
x
[
\
-
_
]
?
1
0
1
$
/
i
Reg
ular
Ex
pressions
101
Reg
ular
Ex
pressions
101
Upgrade to Pro
Enterprise
Regular Expression
r"
(?<!\d)(?:(?:(?:(4[0-9]{12}(?:[0-9]{3})?))|(3[47][0-9]{13})|(?:5[1-5][0-9]{14}))(?!\d))
"
gm
Input 1
1
New
474051514405037899 is NOT Visa 4740515144050,378282246310005 is Visa and Amex 378282246310005,4740515144050 4740515144050,378282246310005 is Visa and Amex 4740515144050378282246310005 is NOT Visa or Amex 4740515144050378282246310005 378282246310005 is Amex Card 378282246310005is Amex a378282246310005 3782822463100059999 is NOT AmexCard 9378282246310005 is NOT AmexCard (?:\D|^)(?:(?:(?:(4[0-9]{12}(?:[0-9]{3})?))|(3[47][0-9]{13}))(?:\D|$)) -using not-capture groups /gm multi-line (?<!\d)(?:(?:(4[0-9]{12}(?:[0-9]{3})?))(?!\d)) -visa using look-around (?<!\d)(?:(?:(?:(4[0-9]{12}(?:[0-9]{3})?))|(3[47][0-9]{13}))(?!\d)) -working (?<!\d)(?:(?:(4[0-9]{12}(?:[0-9]{3})?))|(?:(3[47][0-9]{13}))(?!\d)) visa pattern first not working -incorrectly match even following by digits (?<!\d)(?:(?:(3[47][0-9]{13})|(?:(4[0-9]{12}(?:[0-9]{3})?)))(?!\d)) visa pattern last working correctly (?<!\d)(?:(?:(?:(4[0-9]{12}(?:[0-9]{3})?))|(3[47][0-9]{13})|(?:5[1-5][0-9]{14}))(?!\d)) -Visa,Amex,MC working (?<!\d)(?:(?:(?:(4[0-9]{12}(?:[0-9]{3})?))|(?:5[1-5][0-9]{14})|(3[47][0-9]{13}))(?!\d)) -Visa,MC,Amex working (?<!\d)(?:(?:(3[47][0-9]{13})|(?:(4[0-9]{12}(?:[0-9]{3})?))|(?:5[1-5][0-9]{14}))(?!\d)) -Amex,Visa,MC working
Substitution