I want to remove all special characters from a string. Allowed characters are A-Z (uppercase or lowercase), numbers (0-9), underscore (_), white space ( ), pecentage(%) or the d
StringBuilder sb = new StringBuilder();
foreach (char c in input)
{
if (char.IsLetterOrDigit(c) || "_ %.".Contains(c.ToString()))
sb.Append(c);
}
return sb.ToString();