in reply to regex problem

You may base your regexp on this: (This one matches ), but not those following '. )
$s = "(abcd')'1234)"; $s =~ m/(\(.*?(?<!\')\))/; print $1;
Be careful, I took two assumptions, which fit your sample data:
  1. there is no \'(backslash quot)
  2. if you have ) in quots, it always comes right after the '