从字符串中删除括号点和空格

Bha*_*ran 3 c# asp.net asp.net-mvc

我正在使用asp.net mvc c#.这是我的字符串

string filename = "excluder version(1). final"
Run Code Online (Sandbox Code Playgroud)

我想用结果来连接字符串

filename = "excluderversion1final"
Run Code Online (Sandbox Code Playgroud)

这该怎么做?我不想使用javascript或jquery.需要做后面的代码

Jon*_*eet 8

听起来像是一个很好的候选人Regex.Replace:

private static readonly Regex RemovalRegex = new Regex(@"\s|[().]");
...

public static string RemoveUnwantedCharacters(string input)
{
    return RemovalRegex.Replace(input, "");
}
Run Code Online (Sandbox Code Playgroud)

请注意,这将处理所有空格,而不仅仅是空格字符,您可以轻松修改正则表达式以添加额外的位.