using System; using System.Text.RegularExpressions; public class Test { public static void Main() { String[] tests = new[]{"Q1W2EE3R45T","WWED456J","ABC123"}; foreach (String test in tests) { Console.WriteLine("{0,-15} = {1}", test, Regex.Replace(test, @"[^\d]", String.Empty)); } } }