To solve your original problem, do you need nested regexen? Since you're already in a regex context, you should be able to work up some patterns + embedded code to DWYM.
-QM
--
Quantum Mechanics: The dreams stuff is made of
Comment on Re: Perl segfaulting when using a hairy regex