Breaking News

Visual c# Replace special characters from a string

Share on Google Plus

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

You Might Also Like


Our Logo

Our Logo
Tech Hunters

Like us on Facebook