1.去除文本里的空格
一般情况下去除空格可以使用 Trim()方法,但这种方法只能去掉首尾的空格,字符串内部是无发去除的 可以这么写
public string TirmALL(string textStr) { return textStr.Replace(" ", ""); }
2.去除文本里的换行
public string TirmEnter(string textStr) { string str=textStr.Replace("\n",""); str=str.Replace("\r",""); }
2.去除文本里的html标签
public string TirmEnter(string textStr) { Regex regex = new Regex("<.+?>", RegexOptions.IgnoreCase); string text = regex.Replace(html, "");//替换掉"<"和">"之间的内容 }