$data = '(D,(A,B),C)';; $data =~ s{(\([^(]*A[^)]*\))}{} and print "$1\n$data";; (A,B) (D,,C)