My specific case is a text document that contains lots of text and IPv4 addresses. I want to remove everything except for the IP addresses.
I can use :vglobal<
:vglobal<
Assuming is your regex to match an IP address, I presume you could do something like :
:%s/.\{-}\(\).*/\1/g
where \1 is the first matched group (the address alone), and .\{-} used for non-greedy matching.
\1
.\{-}