in reply to Grep reutrn the occurance of a pattern
This recent entry might be helpful as well...
Re: How can I access the number of repititions in a regex?