I have a .txt file that contains several urls, among all I want to find those that end with zip and rar extension, then change the domain / ip for another and finally save in the same file.
Example of file.txt:
Lorem ipsum dolor sit amet, consectetur http://url.com/file.zip
Curabitur sit amet semper erat http://www.gogle.com/
Cras viverra neque et libero eleifend http://158.989.87.7/file.rar
http://url.com/image.jpg
Output of file.txt
Lorem ipsum dolor sit amet, consectetur http://miserver.com/file.zip
Curabitur sit amet semper erat http://www.gogle.com/
Cras viverra neque et libero eleifend http://miserver.com/file.rar
http://url.com/image.jpg
I know that with regex I can find it, but I come here because I do not know how to start and I have not found something so specific.