I have looked into other posts, and all of them have known unwanted characters. In my case, I have a bunch of characters that I want, and I only want to keep those.
My code is way too messy:
private string RemoveUnwantedChar(string input)
{
string correctString = "";
for (int i = 0; i < input.Length; i++)
{
if (char.IsDigit(input[i]) || input[i] == '.' || input[i] == '-' || input[i] == 'n'
|| input[i] == 'u' || input[i] == 'm' || input[i] == 'k' || input[i] == 'M'
|| input[i] == 'G' || input[i] == 'H' || input[i] == 'z' || input[i] == 'V'
|| input[i] == 's' || input[i] == '%')
correctString += input[i];
}
return correctString;
}
Characters that I want: 0123456789 and numkMGHzVs%-.