日期:2014-05-19  浏览次数:20774 次

请问如何用正则表达式去 空格和括号
各位知道的大侠帮帮忙

------解决方案--------------------
string S = " f asdf(!!!!)f a f a ";
Text = System.Text.RegularExpressions.Regex.Replace(S,
@ "[\s\(\)]+ ", " ");

------解决方案--------------------
String a= "this is a demo(remove space) ";
a=a.Replace( "( ", " ").Replace( ") ", " ");
Regex re = new Regex(@ "\s+ ");
a = re.Replace(a, " ").Trim();
System.Console.WriteLine(a);
System.Console.Read();
------解决方案--------------------
private void b()
{
string str = "A B (C) D ";
this.labeTxt.Text = Regex.Replace(str,@ "\s*\)*\(* ", " ") + "; " ;
}