using System;
using System.Text.RegularExpressions;
public class Program
{
public static void Main()
string S = "587/45-63 58/63";
S = Regex.Replace(S, @"[^0-9]", "");
//The expression @"[^\d]" also would work
Console.WriteLine(S);
}