I am using asp.net mvc c#.This is my string
string filename = "excluder version(1). final"
I want to concatinate string with result
filename = "excluderversion1final"
How to do this? I dont want to use the javascript or jquery. Need to do it code behind
Sounds like a good candidate for Regex.Replace
:
private static readonly Regex RemovalRegex = new Regex(@"\s|[().]");
...
public static string RemoveUnwantedCharacters(string input)
{
return RemovalRegex.Replace(input, "");
}
Note that this will handle all whitespace, not just the space character, and you can easily amend the regular expression to add extra bits.
See more on this question at Stackoverflow