Regular Expression to Match Credit Card Expiration Date

I needed to validate a credit card expiration date and this is the regular expression I cobbled together by looking at various sources.


It’s nearly identical to a regex in this Stack Overflow discussion. All I did was make it work for 01-2020, as well as, 01/2020.

Share Button