How to remove text in brackets using a regular expression

后端 未结 3 643
一生所求
一生所求 2020-12-18 20:44

I\'m looking for a regular expression which will perform the following:

INPUT: User Name (email@address.com)
OUTPUT: User Name

What would b

3条回答
  •  太阳男子
    2020-12-18 21:07

    This should do the job:

    var input = "User Name (email@address.com)";
    var output = Regex.Replace(input, @" ?\(.*?\)", string.Empty);
    

    Note the escaping of the ( and ) chars so that they aren't recognised as group markers.

提交回复
热议问题