The first explicit register is a (you can use any letter az) to use.
:let @a=''
Then run the magic.
:g/useful/yank A
He will look for lines matching the useful pattern, and then run the command :yank A Capital A will be added to register a .
If your vim is configured using the Windows / X global clipboards, you can run
:let @ +=@a
to copy the contents of register a to the clipboard.
progo source share