How to remove special character from unicode string

less than 1 minute read

Here is the sample code to remove special character from Unicode string.

  • Sample Input: SG@%@sgs th? g#%@^@#$ chào^#^$#!abc35 _ sgs _35 hello world không gsg
  • Sample Output: SG%sgs th? g#%^#$ chào^#^$#!abc35 sgs 35 hello world không gsg
class Program
{
    static void Main(string[] args)
    {
        string inputString = "SG@%@sgs thể g#%@^@#$ chào^#^$#!abc35| _ sgs _35 hello world không gsg";
 
        string outputString = inputString.Replace("@", "").Replace("|", "").Replace("_", "");
 
        Console.WriteLine(inputString);
        Console.WriteLine(outputString);
        Console.ReadKey();
    }
}

Tags:

Categories:

Updated: