$_ =~ s/[(]*(?![)]+)//; # Replace 0 or more instances of '(' if the # lookahead assertion for one or more of ')' # fails. This seems to work correctly $_ =~ s/[)]*(?