Note that there are some explanatory texts on larger screens.

plurals
  1. PORegular Expression in gVim to Remove Duplicate Domains from a List
    primarykey
    data
    text
    <p>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: <a href="http://www.vim.org/download.php" rel="nofollow">http://www.vim.org/download.php</a></p> <p>I have a list of over 6,000,000 URLs in a .txt file (which opens in gVim for editing).</p> <p>The URLs are in this format:</p> <pre class="lang-none prettyprint-override"><code>http://www.example.com/some-url.php http://example2.com/another_url.html http://example3.com/ 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 http://example5.com </code></pre> <p>In other words, there is no specific format to the URLs. Some have the WWW, some don't, they all have different formats.</p> <p>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.</p> <p>So it would take the example list posted above, and the end result should look like this:</p> <pre class="lang-none prettyprint-override"><code>http://www.example.com/some-url.php http://example2.com/another_url.html http://example3.com/ http://www.example4.com/anotherURL.htm http://example5.com </code></pre> <p>Here are two nice sites that explain how to use regular expressions within gVim pretty nicely:</p> <p><a href="http://supportweb.cs.bham.ac.uk/documentation/tutorials/docsystem/build/tutorials/gvim/gvim.html#Vi-Regular-Expressions" rel="nofollow">http://supportweb.cs.bham.ac.uk/documentation/tutorials/docsystem/build/tutorials/gvim/gvim.html#Vi-Regular-Expressions</a></p> <p><a href="http://www.softpanorama.org/Editors/Vimorama/vim_regular_expressions.shtml" rel="nofollow">http://www.softpanorama.org/Editors/Vimorama/vim_regular_expressions.shtml</a></p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. COCan you show us some examples of what you've tried so far? One trick for finding/removing duplicates that I've found is to sort the list, first. It's a huge file, so that might be a difficult option for you, but it might also make your regex much simpler.
      singulars
    2. COgVim actually has a very nice feature built in for sorting the URLs, so that's no problem at all. I simply type the following & press enter :sort u That sorts all the lines alphabetically, and then removes duplicate LINES (not domains). As for showing some examples, I haven't gotten very far. Here is one (that I got from this site actually, but gVim says that it isn't a recognized command or regular expression) http://stackoverflow.com/questions/2280666/remove-duplicate-domains-from-list-with-regular-expressions
      singulars
    3. COaccording to gvim's documentation the format to enter what you're looking to do, should be in this format: :start_point,end_points/search_pattern/replacement_pattern/g and this URL gives some simple examples http://147.188.192.43/documentation/tutorials/docsystem/build/tutorials/gvim/gvim.html#Vi-Regular-Expressions ...but my knowledge of regex is nothing at all...until today, I hadn't even heard of it.
      singulars
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload