← Pattern Library PATTERN
Security · Validation
/\b(?:\d[ -]*?){13,16}\b/g
Security · Validation Flags: g
Description
Matches 13–16 digit credit card number shapes that may be separated by spaces or hyphens. It does not check real validity (the Luhn check); it is handy for finding and masking card-number shapes in documents.
Example Matches
4111 1111 1111 1111
5500-0000-0000-0004
Test String
Pay with card 4111 1111 1111 1111
Open this pattern in the tester
Other Patterns