This regular expression
/\\(.*\\)/
won\'t match the matching parenthesis but the last parenthesis in the string. Is there a regular expression
Given a string containing nested matching parentheses, you can either match the innermost sets with this (non-recursive JavaScript) regex:
var re = /\([^()]*\)/g;
Or you can match the outermost sets with this (recursive PHP) regex:
$re = '/\((?:[^()]++|(?R))*\)/';
But you cannot easily match sets of matching parentheses that are in-between the innermost and outermost.
Note also that the (naive and frequently encountered) expression: /\(.*?\)/
will always match incorrectly (neither the innermost nor outermost matched sets).