需要在正则需要帮助的帮助以使用正则提取域
任何人都可以帮助编写一条正则提取以下域的提取域:
如果值为:
dns.google
x2.xdn.cbn.com
hello.1234.extra.net.com
那么我的正则应为我输出如下:
dns.google
----没有匹配x2.xdn。 cbn.com
---提取cbn.com仅hello.1234.extra.net.com
-------------------------------------------仅提取net.com。
我尝试了负面的态度,但失败了。
示例:(?< = \。)。+
Can anyone help to write a regex to extract domains like below:
If values are:
dns.google
x2.xdn.cbn.com
hello.1234.extra.net.com
then my regex should give output to me as below:
dns.google
--- no matchx2.xdn.cbn.com
--- extracts cbn.com onlyhello.1234.extra.net.com
---extracts net.com only.
I tried with negative lookbehind but failed.
Example: (?<=\.).+
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
假设您在一个名为domains.txt的文件中输入了输入,并且您想匹配每个域的最后两个部分,该域具有两个以上的部分,则基于GREP的解决方案可以看起来像这样:
Assuming that you have your input in a file called domains.txt and you would like to match the last two parts of each domain which has more than two parts, a grep-based solution could look like this: