我最初问了这个问题:Regular Expression in gVim to Remove Duplicate Domains from a List
但是,我意识到,如果我“扩大我的范围”以了解我愿意接受的解决方案,我可能更有可能找到一个可行的解决方案。
所以,我会改写我的问题&也许我会得到一个更好的解决方案......这里是:
我在 .txt 文件中有大量 URL 列表(我正在运行 Windows Vista 32 位),我需要删除重复的域(以及每个重复的整个对应的 URL),同时留下每个域的第一次出现。这个特定文件中大约有 6,000,000 个 URL,格式如下(这些 URL 中显然没有空格,我不得不这样做,因为我这里没有足够的帖子来发布那么多“实时” URL ):
http://www.exampleurl.com/something.php http://exampleurl.com/somethingelse.htm http://exampleurl2.com/another-url http://www.exampleurl2.com/a-url.htm http://exampleurl2.com/yet-another-url.html http://exampleurl.com/ http://www.exampleurl3.com/here_is_a_url http://www.exampleurl5.com/something
无论解决方案是什么,使用上述内容作为输入的输出文件应该是这样的:
http://www.exampleurl.com/something.php http://exampleurl2.com/another-url http://www.exampleurl3.com/here_is_a_url http://www.exampleurl5.com/something
您注意到现在没有重复的域,并且它留下了它遇到的第一次出现。
如果有人可以帮助我,无论是使用正则表达式还是我不知道的某些程序,那都很棒。
不过我会这么说,我没有使用 Windows 操作系统以外的任何东西的经验,所以一个需要 Windows 程序以外的东西的解决方案,可以这么说需要一点“婴儿步”(如果有人愿意这样做的话)。