Card RegEx samples explained
Let me explain a few Card number RegEx patterns here.
^3[47][0-9]{5,}$
^
means to start from first character3
- match the first character to be a number3
[47]
- match either4
or7
[0-9]{5,}
- any numerical character, at least5
times or more$
- end of string
So this will match at least 7 or more numerical characters
^4[0-9]{6,}([0-9]{3})?$
Similar as above, except
()?
- it may (or may not) match the pattern inside(
and)
([0-9]{3})?
- maybe 3 numerical characters at the end
^(5[1-5][0-9]{4}|677189)[0-9]{5,}$
(x|y)
- matchx
ory
[0-9]{4}
- exactly 4 numerical characters(5[1-5][0-9]{4}|677189)
- match5[1-5][0-9]{4}
or677189