2

I have a sql dump file that includes entries like this:

INSERT INTO "widgets" VALUES(152,'12477','[email protected]','smtp','Jerry Jo',0);
INSERT INTO "widgets" VALUES(153,'12477','36542','sip','Jerry Jo',0);
INSERT INTO "widgets" VALUES(158,'92865','[email protected]','smtp','Jane Jo',0);

I want to search and replace "VALUES(XXX," with "VALUES(DEFAULT," The number that currently follows the word values can be up to 5 digits long.

So far, I've been playing around with the following commands similar to:

 :%s/\<(VALUES(\d+\>,/VALUES(DEFAULT,/g

But I can't seem to get it right. Any suggestions would be appreciated.

2
  • @Theophrastus can you show me what you mean? Feb 8, 2017 at 20:06
  • @Theophrastus that's failing. It gives me a pattern not found error message Feb 8, 2017 at 20:08

1 Answer 1

7

Use the very magic \v flag to make the regex more like perl and less like vim (which thus requires that the ( be escaped but on the plus side \d+ matches):

:%s/\vVALUES\(\d+/VALUES(DEFAULT

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .