You won't be able to use regular expressions for this problem, because regex only matches regular languages. The pattern you are trying to match is context-sensitive, and therefore not "regular."
Fortunately, it is easy enough to write a parser. Have a look at Per Erik Stendahl's code.