[英]replace increment number in notepad++
i have .sql file dump that have increment id 1 - 1001 I want to replace the number to be null
. 我有增量ID为1-1001的.sql文件转储,我想替换为null
的数字。
This is some .sql content : 这是一些.sql内容:
INSERT INTO `complaint` (`Id`, `complaint_name`) VALUES(2, 'test');
INSERT INTO `complaint` (`Id`, `complaint_name`) VALUES(3, 'BATUK DARAH');
INSERT INTO `complaint` (`Id`, `complaint_name`) VALUES(4, 'SESAK NAFAS');
INSERT INTO `complaint` (`Id`, `complaint_name`) VALUES(5, 'mual dan muntah');
INSERT INTO `complaint` (`Id`, `complaint_name`) VALUES(6, 'muntah darah');
INSERT INTO `complaint` (`Id`, `complaint_name`) VALUES(7, 'batuk rejan');
....
INSERT INTO `complaint` (`Id`, `complaint_name`) VALUES(1001, 'Lorem ipsum');
How to replace automatically using notepad++ ? 如何使用notepad ++自动替换?
Thanks 谢谢
Your requirements are not completely clear, but with this answer you should be able to handle your task. 您的要求还不是很清楚,但是有了这个答案,您应该能够完成任务。
Search for eg 搜索例如
VALUES\(\d+
and replace with 并替换为
VALUES\(
results in 结果是
INSERT INTO
complaint
(Id
,complaint_name
) VALUES(, 'test'); INSERT INTOcomplaint
(Id
,complaint_name
)VALUES(,'test');
make sure to check the search mode "Regular Expression". 确保检查搜索模式“正则表达式”。
\\d+
is matching a sequence of at least one digits. \\d+
匹配至少一个数字的序列。
If you want to also remove the comma, just add it and the following whitespace to the search term VALUES\\(\\d+,\\s*
. 如果您还想删除逗号,只需将其和以下空格添加到搜索词VALUES\\(\\d+,\\s*
。
would result in 会导致
INSERT INTO
complaint
(Id
,complaint_name
) VALUES('SESAK NAFAS'); 将complaint
插入(Id
,complaint_name
)VALUES('SESAK NAFAS');
I am aware that you wanted to replace with null here, but if you ever need to replace with a new incremental value, you could use the column editor (Alt-C) instead of search and replace. 我知道您想在此处替换为null,但是如果您需要替换为新的增量值,则可以使用列编辑器(Alt-C)代替搜索和替换。
First you select the column that you want to have replaced (holding ALT and SHIFT while selecting vertical text), and then press Alt-C to open the column editor, where you can select "number to insert" and type a starting number and increment. 首先,选择要替换的列(选择垂直文本时按住ALT和SHIFT键),然后按Alt-C打开列编辑器,您可以在其中选择“要插入的数字”并键入起始数字和增量。
It is more work than search-and-replace, but still it is extremely helpful in such situations. 它比搜索和替换工作更多,但在这种情况下仍然非常有用。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.