P
Peter
Hi
in my application I get a lot of strings which I have to "clean up"
before I pass them to a third-party library. The strings I have contain
characters which are invalid for the third-party library, so I have to
either remove them or replace them with reasonable alternatives.
What is a good method of doing this?
At the moment I have the following:
string Clean(string element)
{
element = element.Replace(",", "");
element = element.Replace("-", "");
element = element.Replace("!", "");
element = element.Replace("/", "");
element = element.Replace("\\", "");
element = element.Replace("æ", "ae");
element = element.Replace("Æ", "AE");
element = element.Replace("ä", "ae");
element = element.Replace("Ä", "AE");
element = element.Replace("ø", "oe");
element = element.Replace("Ø", "OE");
element = element.Replace("ö", "oe");
element = element.Replace("Ö", "OE");
element = element.Replace("å", "aa");
element = element.Replace("Å", "AA");
element = element.Trim(' ', '.');
return element;
}
Thanks,
Peter
in my application I get a lot of strings which I have to "clean up"
before I pass them to a third-party library. The strings I have contain
characters which are invalid for the third-party library, so I have to
either remove them or replace them with reasonable alternatives.
What is a good method of doing this?
At the moment I have the following:
string Clean(string element)
{
element = element.Replace(",", "");
element = element.Replace("-", "");
element = element.Replace("!", "");
element = element.Replace("/", "");
element = element.Replace("\\", "");
element = element.Replace("æ", "ae");
element = element.Replace("Æ", "AE");
element = element.Replace("ä", "ae");
element = element.Replace("Ä", "AE");
element = element.Replace("ø", "oe");
element = element.Replace("Ø", "OE");
element = element.Replace("ö", "oe");
element = element.Replace("Ö", "OE");
element = element.Replace("å", "aa");
element = element.Replace("Å", "AA");
element = element.Trim(' ', '.');
return element;
}
Thanks,
Peter