Introducing Radical.sh

Forget Code launches a powerful code generator for building API's

Replacing only numbers using Regex in C#

REGEX stands for Regular expression.
Using regex, we can replace the characters,numbers with a string (from 0-9)

Syntax:
Regex regex = new Regex("[Regular expression]");
output = regex.Replace("input_string", "substitution_string");


using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Text.RegularExpressions;

namespace ConsoleApplication1
{
    class Program
    {
        static void Main(string[] args)
        {          

            string filename = "My name is c-sharp 007; (got it !)";
            //find all characters that are letters
            Regex regex = new Regex("[0-9]");
            filename = regex.Replace(filename, "$");

            Console.WriteLine(filename);
                        
        }

    }
}


Output:
My name is c-sharp $$$; (got it !)