How to remove all special characters using regex in C#

1 Answer

0 votes
using System;
using System.Text.RegularExpressions;

class Program
{
    static void Main() {
        String str = "C# 12 c++ (java) *$%*&^python";

        str = Regex.Replace(str, @"[^0-9a-zA-Z]+", "");

        Console.WriteLine(str); 
    }
}




/*
run:

C12cjavapython

*/

 



answered Sep 4, 2023 by avibootz

Related questions

1 answer 144 views
...