Regular Expression to describe Credit Card expiry (valid thru) date

后端 未结 3 522
长情又很酷
长情又很酷 2020-12-11 09:47

I need a regular expression to validate credit card expiry date. Note that the format of the \"date\" is MM/YY where YY is the year without century and MM is the month (from

3条回答
  •  庸人自扰
    2020-12-11 10:50

    Revise the requirement on why you don't need a range for the year... because, 1. the regular expression you accepted as answer fails your acceptance criteria as "12/99900" 2. Even if you had a better regular expression, it's prone to be buggy and more maintenance work as expired date is allowed to be processed...

    in general dynamic data whose limits are changing should not be validated using pattern matching -- unless the pattern changes as well

提交回复
热议问题