1. 程式人生 > >c#刪除字串中指定字元

c#刪除字串中指定字元

string str= System.Text.RegularExpressions.Regex.Replace(字串, "[指定的字元]", "");

如刪除一個字串text中所有的\t\r\n:

string result = System.Text.RegularExpressions.Regex.Replace(text, "[\r\n\t]", "");