One of my favourite modern regex libraries for C++ is Boost.Xpressive, which allows for parsing context-free grammars using recursively nested rules. After fighting with Boost.Spirit (a more formal parser framework) for some time, I achieved what I wanted with Xpressive in a fraction of the time.
From the manual:
The theoretical computer scientists out there will correctly point out that a self-referential regular expression is not "regular", so in the strict sense, xpressive isn't really a regular expression engine at all. But as Larry Wall once said, "the term [regular expression] has grown with the capabilities of our pattern matching engines, so I'm not going to try to fight linguistic necessity here."
From the manual:
The theoretical computer scientists out there will correctly point out that a self-referential regular expression is not "regular", so in the strict sense, xpressive isn't really a regular expression engine at all. But as Larry Wall once said, "the term [regular expression] has grown with the capabilities of our pattern matching engines, so I'm not going to try to fight linguistic necessity here."