While you can theoretically parse a limited amount of nesting in a regex, it's very hard and not worth the effort. It's much easier to do that using a custom python function. See this answer for a good explanation.