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

后端 未结 3 534
长情又很酷
长情又很酷 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:27

    This regexp does the job:

    (0[1-9]|1[0-2])\/[0-9]{2}
    

    Note that it has a capturing group, depending on your regexp engine you can make it non-capturing like this:

    (?:0[1-9]|1[0-2])\/[0-9]{2}
    

提交回复
热议问题