Notepad ++中的正则表达式查找/替换 [英] REGEX in Notepad++ find/replace

查看:106
本文介绍了Notepad ++中的正则表达式查找/替换的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

是否可以在 Notepad++ 中查找/替换的FIND"部分中使用正则表达式的值?

Is it possible to use the value of a regex in the "FIND" part of a find/replace in Notepad++ ?

这是我所拥有的:

FIND: ^.{105}.*(.)
REPLACE: \r\n

要替换的值是我文件中的第 106 个字符.假设它是一个 ~

the value to replace is the 106th character in my file. let's say it's an ~

现在查找/替换应该查找 &替换所有出现的 ~ 并将它们全部替换为 '\r\n'(~ 代表行尾字符)

now the find/replace should find & replace all occurrence of ~ and replace all of them by '\r\n' (the ~ represent the end of line character)

它不起作用,它替换整个字符串而不是第 106 个字符,并且只替换一次而不是多次替换文件.

It doesn't work, it replace the whole string instead of the 106th char and only replace once instead of multiple time on the file.

这样做的全部目的是在热键宏上设置此设置,以便可以快速且经常地完成.

The whole purpose of this is to have this set on a hotkeyed macro so it can be done quickly and often.

推荐答案

我认为您需要以下方面的内容:

I think you want something along these lines:

查找:^(.{105}.)替换:\1\r\n

您需要将事物包装在捕获组中,否则您的 ^ 将强制它仅匹配行的开头.您还需要包含第一个捕获组作为替换字符串的一部分,这样它就不会破坏整个匹配.

You need to wrap the thing in a capture group otherwise your ^ will force it to only match the beginning of the line. You'll also need to include the first capture group as part of the replacement string so it won't nuke the entire matching.

这篇关于Notepad ++中的正则表达式查找/替换的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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