首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > .NET > C# >

请教怎么用正则表达式去 空格和括号

2011-12-19 
请问如何用正则表达式去 空格和括号各位知道的大侠帮帮忙[解决办法]string S f asdf(!!!!)f a f a Te

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

[解决办法]
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*\)*\(* ", " ") + "; " ;
}

热点排行