Hi Rolf, thanks for your reply. I've hopefully made the question clear now, let me know if you have any questions. I think your solution might work. I'm thinking how best to write the parsing regexp in a generally useful way, so that I can use it in the future for other tasks I might think about. Maybe I should both build a result string and a parse tree within the regexp's embedded code then.