Hello All
I have always had a question about find and replace in Vi. As this uses Vi, sed, and RegEx I never knew how or where to post the question but I thought I would give it a shot here. Say I have a text file filled with the following:
Sue, your IP address is 192.168.1.10 which is in the office.
Bob, your IP address is 192.168.1.20 which is in the conference room.
Dan, your IP address is 192.168.1.30 which is in the store room.
Sam, your IP address is 192.168.1.40 which is in the lobby.
Jon, your IP address is 192.168.1.50 which is in the kitchen.
Now say I want to change it to:
Sue, your IP address is 192.168.1.10 for today, which is in the office.
Bob, your IP address is 192.168.1.20 for today, which is in the conference room.
Dan, your IP address is 192.168.1.30 for today, which is in the store room.
Sam, your IP address is 192.168.1.40 for today, which is in the lobby.
Jon, your IP address is 192.168.1.50 for today, which is in the kitchen.
I am not sure how to add the " for today" bit without deleting the rest of the line.
The following RegEx is as far as I can take it. The "???" marks the spot where I need help.
:%s/address is [0-9]{1,3}.[0-9]{1,3}.[0-9]{1,3}.[0-9]{1,3}/??? for today/
I have seen some use of a $1 variable but I haven't had much luck with it. Would anybody be kind enough to clue me in to the secret?
Thanks for reading and have a good day.