No regex query will match stuff like this (since the number of captures is potentially infinite), short of recursive regex stuff (which I think PCRE might support, but I am not sure how it relates to captures). But like other people suggested, using split or similar would be much better in this case, I think. -- Sune.