Answers for "replace multiple occurrences in string c#"

C#
0

replace multiple characters in string c#

string name="$1,300";
Console.Write((name.Replace("$","").Replace(",",""))); // output->  1300
Posted by: Guest on February-23-2021
0

c# string replace multiple matches with one charactar

public static class ExtensionMethods
{
   public static string Replace(this string s, char[] separators, string newVal)
   {
       string[] temp;

       temp = s.Split(separators, StringSplitOptions.RemoveEmptyEntries);
       return String.Join( newVal, temp );
   }
}
// use 
char[] separators = new char[]{' ',';',',','r','t','n'};
string s = "this;is,ratnnntest";

s = s.Replace(separators, "n");
Posted by: Guest on June-23-2021

Code answers related to "replace multiple occurrences in string c#"

C# Answers by Framework

Browse Popular Code Answers by Language