How to remove text in brackets from a string using regular expression in C#

1 Answer

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

namespace ConsoleApplication_C_Sharp
{
    class Program
    {
        static void Main(string[] args)
        {
            var s = "c# vb.net (c c++)";
            var output = Regex.Replace(s, @" ?\(.*?\)", string.Empty);

            Console.WriteLine(output);
        }
    }
}


/*
run:
    
c# vb.net

*/

 



answered Sep 14, 2017 by avibootz
edited Sep 15, 2017 by avibootz

Related questions

...