描述信用卡到期(有效)日期的正则表达式 [英] Regular Expression to describe Credit Card expiry (valid thru) date
本文介绍了描述信用卡到期(有效)日期的正则表达式的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我需要一个正则表达式来验证信用卡到期日.请注意,日期"的格式是 MM/YY,其中 YY 是没有世纪的年份,MM 是月份(从 01 到 12).我不需要 YY 在某个有限的范围内,而只需要 MM.提前致谢.
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 01 to 12). I do not need the YY to be in some limited range but only the MM. Thank you in advance.
推荐答案
这个正则表达式的作用是:
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}
这篇关于描述信用卡到期(有效)日期的正则表达式的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文