in reply to Re^2: regular expression paranthesis remover
in thread regular expression paranthesis remover
Assuming it's about removing balanced parenthesis, I'd go for:
my $balance; # Notice declaring $balance beforehand is important, # otherwise you pick up the global inside (??{}) $balance=qr/(?:[^()]|\((??{$balance})\))*/; $string =~ s/\($balance\)//g;
|
|---|