1

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

INSERT INTO "widgets" VALUES(152,'12477','abc@gmail.com','smtp','Jerry Jo',0);
INSERT INTO "widgets" VALUES(153,'12477','36542','sip','Jerry Jo',0);
INSERT INTO "widgets" VALUES(158,'92865','me@gmail.com','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.

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

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

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.