Sep. 12th, 2007

hollyking: (hacker)

I'm switching from Emacs to VIM for a variety of reasons. One thing that I can't seem to figure out how to do is perform a substitution using a regular expression with captures. What I have is:

"Offer_ID","Product_ID","Offer_ID","CodeText"
3000,0,3000,12345
3001,10,3001,67890
3002,42,3002,67890
3003,40,3003,67890

What I want is:

"Offer_ID","Product_ID","CodeText"
3000,0,12345
3001,10,67890
3002,42,67890
3003,40,67890

I think it would be easy using a command like %s/^\(\d+,\)\(\d+,\)\d+,\(\d+\)$/\1\2\3/, but all I get is the error message "Pattern not found." Looking at the VIM help the syntax looks right and I've made sure that magic is set. So I don't know what's going wrong.

What's wrong with my substitution?

Update: Fixed typos in the post that weren't used in VIM.

Profile

hollyking: (Default)
hollyking

March 2013

S M T W T F S
     12
3456789
1011 1213141516
17181920212223
24252627282930
31      

Most Popular Tags

Style Credit

Expand Cut Tags

No cut tags
Page generated Jul. 17th, 2025 06:37 am
Powered by Dreamwidth Studios