Need help finding or having a RegEx match a MM/YY or MM/YYYY format. My RegExFu is weak and I\'m not even sure where to begin writing this.
Months should be 1-12, y
Try:
var re = new Regex(@"(?\d{2})/(?\d{2}|\d{4})"); var month = re.Match(yourString).Groups["month"]; ...
An alternative is:
if(dateStr.Length == 5) myDateTime = DateTime.ParseExact("MM/YY", dateStr); else myDateTime = DateTime.ParseExact("MM/YYYY", dateStr);