c#中如何过滤掉文本框中得制表,换行,回车,空格。最好写出代码

2024-12-22 14:16:34
推荐回答(2个)
回答1:

string test = "test\ttest\n test\r";
string pa=@"[\t\n\r\s]";
string text = System.Text.RegularExpressions.Regex.Replace(test, pa, "", System.Text.RegularExpressions.RegexOptions.IgnoreCase);
textBox1.Text = text;

回答2:

Regex.Replace(input,"\s","");