【发布时间】:2012-05-04 09:45:06
【问题描述】:
我需要将日期字符串匹配为 1 或 2 个数字。
[StringLength(2)]
[RegularExpression(@"\d{1,2}", ErrorMessage = "Date must be 1- 2 numbers")]
public string Date { get; set; }
我需要对 Year 进行类似操作以匹配 4 位字符串。 请问我在这里做错了什么?
【问题讨论】:
标签: regex asp.net-mvc-3 data-annotations