Visual c# Replace special characters from a string
The following function will replace special characters from
a string with single space.
Regex.Replace(str,
"[^a-zA-Z0-9_.*\n\u2022 ]+", "")
public string RemoveSpecialCharacters(string str)
{
String val =
Regex.Replace(str, "[^a-zA-Z0-9_.*\n\u2022 ]+", "");
// return
val.Replace("*", "\r\n \u2022");
return val;
}
The above function must be called in the appropriate textbox
where you want this function to work.Like this:-
Textbox1.Text = RemoveSpecialCharacters(Textbox1.Text.ToString());
Above code is functional.If you find any problem in applying
this , please contact us. Visit
our website www.bel-technology.com
0 comments