in reply to Re^2: regular expression paranthesis remover
in thread regular expression paranthesis remover

Fails on the perfectly balanced "12(34)56(78)9"

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;