This can be done with either regex+substitute or macros
Substitute. This is the same as your regex except the important parts are surrounded by \( . \) to create capture groups. These are referred to by submatch(1) and submatch(2) respectively. We use the replace expression \= and execute('let') idiom. Finally, use /n to prevent substitution from ...
I use "very magic" setting (\v) so that I can use normal regex patterns and not have to convert it into vim's awkward regex format.
First, I would do search as the original regex search term, but prepend with \v to enable "very magic" regex setting:
After testing it to make sure it is working correctly, I'd finally do search/replace ...
There is another way that doesn't move the cursor nor requires :exe, but uses other tricks. Here I count by using a function that modifies and returns something (if += was an expression like in C, it would have been simpler)
command! -nargs=1 -range Count call s:Count2(<f-args>, <line1>,<line2>)
" Not using the usual :function-range to ...
Warning: The accepted answer does not return a number or number-like object. This does.
function! Count( word )
redir => cnt
silent exe '%s/' . a:word . '//n'
return matchstr( cnt, '\d\+' )
With the same instructions as the accepted answer, except you can actually perform further calculations with the result, e.g.: