regular expression dates
# Montag 28.03.2011
# Mi, 23.03.11
^([1-9]|0[1-9]|[12][0-9]|3[01])[-/.]([1-9]|0[1-9]|1[012])[- /.][0-9]{4} or with \d{2}[.]\d{2}[.]\d{4}
works for 28.03.2011 but not for 23开发者_StackOverflow中文版.03.11. can i automatically add 20 before 11 if year is just 11?
^([1-9]|0[1-9]|[12][0-9]|3[01])[-/.]([1-9]|0[1-9]|1[012])[- /.]([0-9]{4}|[0-9]{2})$
How about the above
By the way this is just pattern matching so it will match invalid dates too. eg:30.02.2011
Why not use one of the methods available in the System.DateTime
namespace? You could use DateTime.TryParseExact()
精彩评论