Reputation: 1738
i have .sql file dump that have increment id 1 - 1001
I want to replace the number to be null
.
This is some .sql content :
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++ ?
Thanks
Upvotes: 0
Views: 4936
Reputation: 842
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.
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.
It is more work than search-and-replace, but still it is extremely helpful in such situations.
Upvotes: 0
Reputation: 92986
Your requirements are not completely clear, but with this answer you should be able to handle your task.
Search for e.g.
VALUES\(\d+
and replace with
VALUES\(
results in
INSERT INTO
complaint
(Id
,complaint_name
) VALUES(, 'test');
make sure to check the search mode "Regular Expression".
\d+
is matching a sequence of at least one digits.
If you want to also remove the comma, just add it and the following whitespace to the search term VALUES\(\d+,\s*
.
would result in
INSERT INTO
complaint
(Id
,complaint_name
) VALUES('SESAK NAFAS');
Upvotes: 2