in reply to regex extraction for variable number of args
hi,
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;
|
---|
Replies are listed 'Best First'. | |
---|---|
Re^2: regex extraction for variable number of args
by clueless newbie (Curate) on Jul 22, 2012 at 14:33 UTC |
In Section
Seekers of Perl Wisdom