使用正则表达式从列表中删除重复的域 [英] Remove duplicate domains from list with regular expressions

查看:22
本文介绍了使用正则表达式从列表中删除重复的域的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想使用 PCRE 获取 URI 列表并对其进行提取.

I'd like to use PCRE to take a list of URI's and distill it.

开始:

http://abcd.tld/products/widget1       
http://abcd.tld/products/widget2    
http://abcd.tld/products/review    
http://1234.tld/

完成:

http://abcd.tld/products/widget1
http://1234.tld/

亲爱的 StackOverflow 成员有什么想法吗?

Any ideas, dear members of StackOverflow?

推荐答案

你可以使用像 uniq.

请参阅评论中的 kobi 示例:

See kobi's example in the comments:

grep -o "^[^/]*//[^/]*/" urls.txt | sort | uniq

这篇关于使用正则表达式从列表中删除重复的域的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆