是的,您可以使用此模式
   v                   v
 (\([^\)\(]*)+([^\)\(]*\))+
 ------------ -------------
      |            |
      |            |->match all (right)brackets to the right..
      |
      |->match all (left)brackets to the left
演示
如果您有这样的递归模式,上述模式将不起作用
(i want(to) (extract and also (this)) this text)
                              ------
            -------------------------
在这种情况下,您可以使用elclanrs 推荐的递归模式
您也可以在不(使用正则表达式的情况下通过维护和的数量来做到这一点)
所以,假设noOfLB是 的计数是(的noOfRB计数) 
- 继续迭代字符串中的每个字符并保持first的位置 
( 
- 如果发现 (
 
- 如果你发现增加 noOfRB )
 
- if noOfLB==noOfRB,你找到了last的最后位置 
) 
我不知道php所以我会在c#中实现上面的算法
public static string getFirstRecursivePattern(string input)
{
    int firstB=input.IndexOf("("),noOfLB=0,noOfRB=0;
    for(int i=firstB;i<input.Length && i>=0;i++)
    {
         if(input[i]=='(')noOfLB++;
         if(input[i]==')')noOfRB++;
         if(noOfLB==noOfRB)return input.Substring(firstB,i-firstB+1);
    }
    return "";
}