I think you're looking for the balance parenthesis regex of Jeffery Friedl. After tweeking for quoted strings it looks something like ...
my ($np); # The initial balance parentheses expression with an embedded set is: # $np=qr/\( ([^()] | (??{$np})) *\)/x; # And quoted strings are "(?:[^"]|\")*" and '(?:[^']|\')*' or ('|")(? +:[^\1]|\\1)*\1 so $np=qr/ \( # The opening "(" (( # We'll want this hence the cap +turing () '(?:[^']|\')*?' #' a single quote string | "(?:[^"]|\")*?" #" a double quote string | [^()] # not a parentheses | (??{$np}) )*) \) # and the closing ")" /x;
In reply to Re: regex extraction for variable number of args
by clueless newbie
in thread regex extraction for variable number of args
by NetWallah
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |