// Collection of code snippets by Arne Vajhøj // (likely posted to comp.os.vms/INFO-VAX, INFO-TPU, MACRO32, eksperten.dk, newz.dk, LinkedIn or other place sometime between 1990 and now) using System; using System.Globalization; using System.Text.RegularExpressions; namespace E { public class Program { private static Regex re = new Regex(@"\d\d:\d\d:\d\d\.\d\d"); public static bool Test1(string s) { return re.IsMatch(s); } public static bool Test2(string s) { DateTime dt; return DateTime.TryParseExact(s, "HH:mm:ss.ff", new CultureInfo("da-DK"), DateTimeStyles.AllowLeadingWhite | DateTimeStyles.AllowTrailingWhite, out dt); } public static void Test(string s) { Console.WriteLine(s + " : " + Test1(s) + " " + Test2(s)); } public static void Main(string[] args) { Test("00:00:04.05"); Test("00:00:X4.05"); Test("00:00:94.05"); } } }