// 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.Collections.Generic; using System.Globalization; using System.Text.RegularExpressions; namespace E { public class Program { private static Regex re = new Regex(@"\d{2,2}\.\d{2,2}\.\d{4,4}", RegexOptions.Compiled); public static List FindDates(string s) { List res = new List(); foreach(Match m in re.Matches(s)) { res.Add(DateTime.ParseExact(m.Value, "dd.MM.yyyy", CultureInfo.InvariantCulture)); } return res; } private static void Test(string s) { Console.WriteLine(s); List dtlst = FindDates(s); foreach(DateTime dt in dtlst) { Console.WriteLine(dt); } } public static void Main(string[] args) { string s1 = "RE120526~Day tour~asd~Hogni~Gylfason~finnur@atom01.is~asd ~asd~Germany~12312312~hotel_borg~asflæasdfjka as fas f~~~~ Hogni Gylfason~09.10.2008 01:21~atom01~Golden Circle~EUR~RE-04~24.10.2008~1~0~0~~83~"; string s2 = "RE120502~Day tour~asd~Hogni~Gylfason~finnur@atom01.is~asd ~asd~Germany~12312312~hotel_fron~Comments~~~~ Hogni Gylfason~07.10.2008 01:37~110~Golden Circle~EUR~RE-04~30.10.2008~2~2~2~~83~"; Test(s1); Test(s2); } } }