Notepad++ 记事本++;动态替换
我需要更换这一行:Notepad++ 记事本++;动态替换,notepad++,Notepad++,我需要更换这一行: tvec.at(21).interrupt(); if (thr_ev_21.get()) thr_ev_21->interrupt(); 这一行: tvec.at(21).interrupt(); if (thr_ev_21.get()) thr_ev_21->interrupt(); 我有很多不同数字的这类行(例如22、23、24等) 记事本++(v7.5.3)中是否有一种方法可以这样动态替换: tvec.at(X).interrupt(); -->
tvec.at(21).interrupt();
if (thr_ev_21.get()) thr_ev_21->interrupt();
这一行:
tvec.at(21).interrupt();
if (thr_ev_21.get()) thr_ev_21->interrupt();
我有很多不同数字的这类行(例如22、23、24等)
记事本++(v7.5.3)中是否有一种方法可以这样动态替换:
tvec.at(X).interrupt();
-->
- Ctrl+H
- 查找内容:
tvec\.at\(\d+)。中断\(\)代码>
- 替换为:
if\(thr\u ev\u1.get\(\)\)thr\u ev\u1->interrupt\(\)代码>
- 检查环绕
- 检查正则表达式
- 全部替换
tvec\.at\( : literally, dot and parenthesis have to be escaped
(\d+) : group 1, 1 or more digits
\).interrupt\(\) : literally, dot and parenthesis have to be escaped
注:
使用记事本++,必须在替换零件中转义括号。- Ctrl+H
- 查找内容:
tvec\.at\(\d+)。中断\(\)代码>
- 替换为:
if\(thr\u ev\u1.get\(\)\)thr\u ev\u1->interrupt\(\)代码>
- 检查环绕
- 检查正则表达式
- 全部替换
tvec\.at\( : literally, dot and parenthesis have to be escaped
(\d+) : group 1, 1 or more digits
\).interrupt\(\) : literally, dot and parenthesis have to be escaped
注:
使用记事本++,必须在替换部分中转义括号。将搜索模式更改为“正则表达式”,然后替换:
tvec.at\((\d+)\).interrupt\(\);
与:
注:
- 搜索/替换字符串中的所有实际括号都必须用反斜杠转义,因为它们在正则表达式中有特殊含义。您需要对
和其他一些我忘记的字符执行相同的操作[]{}?*
- 搜索字符串(
)中任意数字的匹配项放在括号中,因此它形成一个捕获组。由于它是第一个这样的组,您可以在替换字符串中将其称为\d+
。(在替换中多次引用它也没有问题。)\1
tvec.at\((\d+)\).interrupt\(\);
与:
注:
- 搜索/替换字符串中的所有实际括号都必须用反斜杠转义,因为它们在正则表达式中有特殊含义。您需要对
和其他一些我忘记的字符执行相同的操作[]{}?*
- 搜索字符串(
)中任意数字的匹配项放在括号中,因此它形成一个捕获组。由于它是第一个这样的组,您可以在替换字符串中将其称为\d+
。(在替换中多次引用它也没有问题。)\1
[^\s]+
)使用\1
或\2
(如果是第二组)。注意:您可以创建如下字符串捕获组:([^\s]+
)使用\1
或\2
(如果是第二组)。