in reply to anchor text match

As Anonymonk points out, the answer to “Is there a good way to parse $nested_format with a regex?” is (almost always) no. You say you've tried some members of the HTML:: family of modules; if you show the code you came up with in your attempts, then it'll be a lot easier to see how to adapt it for your needs.