I need a regular expression written to use in gVim that will remove duplicate domains from a list of URLs (gVim can be downloaded here: http://www.vim.org/download.php
I have a list of over 6,000,000 URLs in a .txt file (which opens in gVim for editing).
The URLs are in this format:
http://www.example.com/some-url.php
http://example2.com/another_url.html
http://www.example4.com/anotherURL.htm
http://www.example.com/some-url2.htm
http://example.com/some-url3.html
http://www.example2.com/somethingelse.php
In other words, there is no specific format to the URLs. Some have the WWW, some don't, they all have different formats.
I need a regular expression written for gVim that will remove all duplicate DOMAINs from the list (and it's corresponding URL), leaving behind the first instance it finds.
So it would take the example list posted above, and the end result should look like this:
http://www.example.com/some-url.php
http://example2.com/another_url.html
http://www.example4.com/anotherURL.htm
Here are two nice sites that explain how to use regular expressions within gVim pretty nicely:
http://www.softpanorama.org/Editors/Vimorama/vim_regular_expressions.shtml