using System; using System.Text.RegularExpressions; public class Test { public static void Main() { string txt = "e1e2e3"; Regex digits = new Regex(@"\d"); Random rand = new Random(); txt = digits.Replace(txt, match => rand.Next(0, 9).ToString()); Console.WriteLine(txt); } }