in reply to minimal matching regex

See perlre for the non-greedy match operators, or maybe better, only capture the things you want to keep instead of capturing everything and later on figuring out what you don't want to keep.

How about using \w+ instead of .+ in your first capture?