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("[^a-zA-Z0-9]"); filename = regex.Replace(filename, "$"); Console.WriteLine(filename); } } }
My$name$is$C$SHARP$007$$$got$it$$$