I have a fairly elaborate regex string for finding IP addresses (25[0-5]|2[0-4][0-9]|[0-1][0-9]{2}|[0-9]{1,2}. etc.) If, for instance, I want to get all instances of the IP address, I have to delete everything in the line prior to the instance, and in a second call, I have to delete everything after the instance. Is there a way that I could store the search string as a variable to use in multiple replacements?
For instance:
Store the string in register "a"
:y a 25[0-5]|2[0-4][0-9]|[0-1][0-9]{2}|[0-9]{1,2}\. . .
Refer back to register "a" when deleting everything before the address
:%s/^.*(\a)/\1/g
And again when deleting everything after it
:%s/(\a).*$/\1/g
BTW, I know you can delete before and after the parenthetical. I'm just using that as an example.