.NET Fiddle

CSharp · Console

/Program.cs

using System;
using System.Text.RegularExpressions;
					
public class Program
{
	public static void Main()
	{
		string pattern = @"\(([^\)]+)\)";
        string input = @"x^(3*x+1) + (cos x)";
        RegexOptions options = RegexOptions.IgnoreCase;
        
        foreach (Match m in Regex.Matches(input, pattern, options))
        {
            Console.WriteLine("'{0}' found at index {1}.", m.Value, m.Index);
        }
	}
}
;