📌  相关文章
📜  c#字符串用一个字符替换多个匹配项 - 任何代码示例

📅  最后修改于: 2022-03-11 15:00:51.754000             🧑  作者: Mango

代码示例2
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,\ra\t\n\n\ntest";

s = s.Replace(separators, "\n");