Regex · Credit card number · Free
Credit card number regex.
Loosely matches a 13–16 digit credit card number with optional spaces or dashes. (Validate with the Luhn check for real use.) Copy the pattern below, see what it matches, then tweak it for your exact case with the free generator.
The pattern
/\b(?:\d[ -]?){13,16}\b/g
✓ Matches
4111 1111 1111 11115500-0000-0000-00044111111111111111✗ Doesn't match
1234card numberabcd efghNeed a variation? Generate one
Other common patterns
Parsing and pattern-matching are everywhere in AI systems. MindloomHQ teaches you to build them for real — agents, RAG, pipelines — with projects and certificates.
Explore MindloomHQ →