// 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 = "ab{123}cd{35416}ef{131234}gh{745636}ij"; string s2 = s; MatchCollection res = Regex.Matches(s, "{([0-9]+)}"); for(int i = 0; i < res.Count; i++) { s2 = s2.Replace(res[i].Groups[0].ToString(), res[i].Groups[1].ToString()); } Console.WriteLine(s + " -> " + s2); } }