C# 删除边界内的字符串

C# remove string inside bounderies

抱歉,如果这是重复的或其他什么,但我无法在 c# 中找到解决我的问题的方法。我的 c# string 看起来像这样:

string aa = "First Example (first to delete) , Second example ( Second to delete ) , Thrird Example ( Third to delete )"

我想从这个字符串中删除 ( SOME INPUT )() 中的所有内容。

问题是我不知道这个 SOME INPUT 是什么。我只知道在().

里面

感谢您的帮助。

https://dotnetfiddle.net/Jnhszs

using System;
using System.Text.RegularExpressions;

public class Program
{
    public static void Main()
    {
    var text = "First Example (first to delete) , Second example ( Second to delete ) , Thrird Example ( Third to delete )";

    text = Regex.Replace(text, @"\([^)]*\)", "");
    text = Regex.Replace(text, @"\s{2,}", " ");

    Console.WriteLine(text);
    }
}

输出:第一个例子,第二个例子,第三个例子