This RegEx pattern matches months (not minutes) in Excel Date format syntax.
As specified in §3.8.31 numFmts (Number Formats) in part 4 of the spec (p.2140 in v.1.4):
Month versus minutes
Why-oh-why would you use 'm' for both? Especially when normal syntax in .NET is to use 'M' for month and 'm' for minutes! ARGH&@/#&/¤&%#!!
Well to make up for it when applying a DateTimeFormatInfo format pattern (eg. myDate.ToString("MM/dd/yy")) i have created a regular expression that matches the month-only values of m,mm etc.
Oh well seems theres an issue as well regarding hours, since Excel specifies 'h' no matter if its AM or PM where .NET DateTimeFormatInfo format pattern dictates h for 0-11 and H for 0-23. If i get the time ill get back with a pattern for that one as well.
(?xnm: (?<! # must not be at the left of match h{1,2}\]?:?m? # match one or two occurrences of h followed by zero or 1 occurrences of ] or : or m (m: since one m is allowed we need this) ) (?<month>mmmmm|mmmm|mmm|mm|m) # match (?! # must not be at the right of match m?:?\]?s{1,2} # match one or zero occurrences of m or : or ] followed by one or more s (m: since one m is allowed we need this) ))
Note that not all parsers support Ignore Whitespace, so you might need to remove comments.
Hope somebody finds this useful.
Please post comments and possible bugs -its not tested thorougly yet
AndersR