發(fā)布時(shí)間:2018-03-06 16:20 作者:獨(dú)孤劍 閱讀:1015
static void Main(string[] args) { // length=15 or 18 ^([1-9]\d{7}((0\d)|(1[0-2]))(([0|1|2]\d)|3[0-1])\d{3})|([1-9]\d{5}[1-9]\d{3}((0\d)|(1[0-2]))(([0|1|2]\d)|3[0-1])((\d{4})|\d{3}[A-Za-z]))$ // length=15 ^[1-9]\d{7}((0\d)|(1[0-2]))(([0|1|2]\d)|3[0-1])\d{3}$ // length=18 ^[1-9]\d{5}[1-9]\d{3}((0\d)|(1[0-2]))(([0|1|2]\d)|3[0-1])((\d{4})|\d{3}[A-Za-z])$ string cardid = "220123199912121234"; // 正則驗(yàn)證 if (System.Text.RegularExpressions.Regex.IsMatch(cardid, @"^([1-9]\d{7}((0\d)|(1[0-2]))(([0|1|2]\d)|3[0-1])\d{3})|([1-9]\d{5}[1-9]\d{3}((0\d)|(1[0-2]))(([0|1|2]\d)|3[0-1])((\d{4})|\d{3}[A-Za-z]))$")) { Console.WriteLine("true"); } else { Console.WriteLine("false"); } Console.ReadLine(); }
微信打賞, 微信掃一掃
支付寶打賞, 支付寶掃一掃
如果文章對(duì)您有幫助,歡迎給作者打賞