Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR CSHARP

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[]{' ',';',',','
','	','
'};
string s = "this;is,
a	


test";

s = s.Replace(separators, "
");
Source by stackoverflow.com #
 
PREVIOUS NEXT
Tagged: #string #replace #multiple #matches #charactar
ADD COMMENT
Topic
Name
2+2 =