// 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.Text.RegularExpressions; class MainClass { public static void Main(string[] args) { string s = "bla bla http://www.eksperten.dk bla bla http://eksperten.dk bla bla"; MatchCollection res = Regex.Matches(s,"http://[^ ]* "); for(int i = 0; i < res.Count; i++) { string link = res[i].Value; Console.WriteLine(link); } Regex r; Match m; r = new Regex("http://[^ ]* ",RegexOptions.IgnoreCase|RegexOptions.Compiled); for (m = r.Match(s); m.Success; m = m.NextMatch()) { Console.WriteLine(m.Groups[0]); } } }