0

I need to do a check for multiple special characters and replace them later with regular letters. I've tried to use Regex and regular expressions like this:

if (Regex.IsMatch(toCheck, @"[^&\,\ß]"))
{
    toCheck = toCheck.Replace("&", "and");
    toCheck = toCheck.Replace(",", "");
    toCheck = toCheck.Replace("ß", "ss");

    return toCheck;
}

And the problem is that Regex apparently does not work with ASCII codes, like ß or Ö, Æ, Å, Ä are, since I am getting an exception about not knowing what \ß is. Is there any other way to check multiple characters in string that is easier than to write big if loop like:

if(toCheck.Contains("Ö") || toCheck.Contains("Æ") || ... )

Because I have to do that for 15 special symbols and it will be kind of messy.

nemo_87
  • 4,523
  • 16
  • 56
  • 102

0 Answers0