This is my lame excuse for a routine to remove special characters from a string (I just want the spaces preserved so I can then turn it into a CamelCase variable name... is there a better way?
static public string removeSpecialCharacters(st
ring orig)
{
string rv;
// replacing with space allows the camelcase to work a little better in most cases.
rv = orig.Replace("\\"," ");
rv = rv.Replace("("," ");
rv = rv.Replace(")"," ");
rv = rv.Replace("/"," ");
rv = rv.Replace("-"," ");
rv = rv.Replace(","," ");
rv = rv.Replace(">"," ");
rv = rv.Replace("<"," ");
rv = rv.Replace("-"," ");
rv = rv.Replace("&"," ");
// single quotes shouldn't result in CamelCase variables like Patient's -> PatientS
// "smart" forward quote
rv = rv.Replace("'","");
// if you have to find any more weird unicode chars, look here:
//
http://seth.positivism.org/man.cgi/7/groff_char rv = rv.Replace("\u2019",""); // smart forward (possessive) quote.
// make sure to get rid of double spaces.
rv = rv.Replace(" "," ");
rv = rv.Replace(" "," ");
rv = rv.Trim(' '); // Remove leading and trailing spaces.
return(rv);
}
Thanks!
-Kelly
Start Free Trial