Hi, thanks for your quickly answer. I never noted that negative lookahead is a 
zero-string match and that I had to put again the string that I want to change 
(the four digits). Your solution works very fine.
Regards,
César V.

Date: Fri, 8 Jun 2012 01:11:25 -0700From: 
[email protected]
To: [email protected]
Subject: RE: How to find and replace using negative lookahead



        César Valencia wrote:

> Hi, I want to find all the strings the has "K Value=" not

> followed by 0000 and replace them for "K Value=1300".

> This is my original text:

>

> K Value=0010, P Value=1025, Z Value=2000

> K Value=2051, P Value=0310, Z Value=5110

> K Value=0000, P Value=5025, Z Value=9000

>

> and the result should be:

>

> K Value=1300, P Value=1025, Z Value=2000

> K Value=1300, P Value=0310, Z Value=5110

> K Value=0000, P Value=5025, Z Value=9000

I would try a negative lookahead, like this:


:%s/K Value=\%(0000\)\@!\zs\d\{4}/1300/g


That finds "K Value=" not followed by "0000" but followed by

four digits. It then changes the four digits to "1300".


Not tested much!


John


-- 

You received this message from the "vim_use" maillist.

Do not top-post! Type your reply below the text you are replying to.

For more information, visit http://www.vim.org/maillist.php

        
        

        

        
        
                If you reply to this email, your message will be added to the 
discussion below:
                
http://vim.1045645.n5.nabble.com/How-to-find-and-replace-using-negative-lookahead-tp5708861p5708864.html
        
        
                
                To unsubscribe from How to find and replace using negative 
lookahead, click here.

                NAML
                                                  

--
View this message in context: 
http://vim.1045645.n5.nabble.com/How-to-find-and-replace-using-negative-lookahead-tp5708861p5708939.html
Sent from the Vim - General mailing list archive at Nabble.com.

-- 
You received this message from the "vim_use" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php

Reply via email to