Regular Expressions (RegEx) are a powerful tool for searching for text that matches specific patterns, but it is also a complex tool that requires care and attention to detail. There are many caveats to using RegEx.Here, I would like to briefly talk about a common caveat when using RegEx: the set operator [ ] and its effect on the contained tokens...
[ ]
The most commonly used methods for parsing textual data into DateTime or DateTimeOffset values are different overloads of DateTime.Parse and DateTimeOffset.Parse. However, for many formats these methods throw a FormatException when they attempt to perform the conversion, and their corresponding TryParse overloads all return false. The .NET Framework provides two alternative method families: ParseExact and TryParseExact, that can be used to parse the string representations of date and time values. This article explores their usage.