We need a C# function which will remove all special characters from a string.
Also, is it possible to change "George's" to "George" (remove both single quote and character s)?
See Question&Answers more detail:osWe need a C# function which will remove all special characters from a string.
Also, is it possible to change "George's" to "George" (remove both single quote and character s)?
See Question&Answers more detail:osThis method will removed everything but letters, numbers and spaces. It will also remove any ' or " followed by the character s.
public static string RemoveSpecialCharacters(string input)
{
Regex r = new Regex("(?:[^a-z0-9 ]|(?<=['"])s)", RegexOptions.IgnoreCase | RegexOptions.CultureInvariant | RegexOptions.Compiled);
return r.Replace(input, String.Empty);
}