Answers for "C# use regex to replace characters found in a string"

C#
3

c# regex replace

Regex.Replace(
  "input string", @"[a-zA-Z]+", "replace string"
);
Posted by: Guest on May-21-2020
0

c# replace characters in string that are invalid using regex

string pattern = "[\~#%&*{}/:<>?|"-]";
string replacement = " ";

Regex regEx = new Regex(pattern);
string sanitized = Regex.Replace(regEx.Replace(input, replacement), @"s+", " ");

This will replace runs of whitespace with a single space as well.
Posted by: Guest on June-16-2021
-2

c# replace regex string

string pattern = @"bwestb";
string modifiedString = Regex.Replace(input, pattern, strReplacement, RegexOptions.IgnoreCase);
Posted by: Guest on January-28-2021

Code answers related to "C# use regex to replace characters found in a string"

C# Answers by Framework

Browse Popular Code Answers by Language