I have a regular expression question...

Discussion in 'Web Design & Coding' started by Complete, Jul 12, 2011.

  1. Complete

    Complete OSNN Addict

    Messages:
    94
    I have a regular expression question...
    How would I use regular expressions to remove the contents in parenthesis in a string in C# like this:
    "SOMETHING (#2)"
     
  2. Complete

    Complete OSNN Addict

    Messages:
    94
    According to:

    Regex Class (System.Text.RegularExpressions)

    I have gotten some results like this:
    string pattern = @"\(#\d+\)";
    [SIZE=2][COLOR=#2b91af]Regex[/COLOR][/SIZE] rgx = [SIZE=2][COLOR=#0000ff]new[/COLOR][/SIZE] [SIZE=2][COLOR=#2b91af]Regex[/COLOR][/SIZE](pattern, [SIZE=2][COLOR=#2b91af]RegexOptions[/COLOR][/SIZE].IgnoreCase);
    [COLOR=#2b91af][FONT=Consolas][SIZE=2][COLOR=#2b91af][FONT=Consolas][SIZE=2][COLOR=#2b91af]MatchCollection[/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][/COLOR][FONT=Consolas][SIZE=2] matches = rgx.Matches(interesting_string);[/SIZE][/FONT]
    [FONT=Consolas][SIZE=2][/SIZE][/FONT]
    [FONT=Consolas][SIZE=2]But I do not know what to do with the matches or what to do after this.
    [/SIZE][/FONT]