http://www.perlmonks.org?node_id=38334


in reply to RegExp Help Needed

It depends on how robust you need to be. If you don't care about things like `(that "smarts (especially like this)!")', you could do:

s/"(?![^(]*\))/"/g

If you really need to have it balance correctly with escaped or quoted parens, you'll probably want to look at a module (I've heard good things about Text::Balanced and I suspect it could help here, but having never worked with it I'll defer to others).

-dlc