如何在常用文本编辑器中执行否定搜索(或替换) [英] How to perform negative search (or replace) in common text editors

查看:39
本文介绍了如何在常用文本编辑器中执行否定搜索(或替换)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有什么办法可以在记事本++或崇高文本等文本编辑器中替换在我的搜索查询中不匹配的所有单词/行.

Is there any way I can replace all the words/lines which don't match in my search query in text editors like notepad++ or sublime text.

例如,我有一个包含很少 url 链接的文档.我可以做一些只在我的文档中留下 url 链接的事情吗?如果我必须删除 url 链接,我可以使用正则表达式搜索它们并用空字符串替换它们.但是对于与正则表达式不匹配的内容,我可以做同样的事情吗?

For example I have a document having few url links in it. Can I do something which leaves only url links in my document. If I have to remove url links, I can search them using regex and replace them with an empty string. But can I do the same thing but for the content which doesn't match regex.

示例:

这是我想删除的行,也可以在其中包含特殊字符链接 % $ [] (0) 和这里是网址:https://google.com 另一行带有一些随机垃圾和 https://www.example.com

this is line which I want to remove and can also have special characters in it link % $ [] (0) and here is url: https://google.com one more line with some random garbagee and https://www.example.com

对于上面的文本,输出应该是:

For above text, output should be:

https://google.com

https://www.example.com

推荐答案

SynWrite 应用程序中:

  • 调用对话框搜索/提取字符串"
  • 输入正则表达式作为 URL,执行查找"
  • 现在按下按钮将找到的 URL 复制到新标签

这篇关于如何在常用文本编辑器中执行否定搜索(或替换)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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