thorondor1990
thorondor1990

Reputation: 81

Vim multiline search using Negative lookahead

I was trying to search the following pattern in a log.

[write_<many other characters here till end of line>
<10-15 lines here>
<more characters> 10008

My log has many such occurrences with the last value not being 10008. First I tried searching this like this :

/\[write_\_.\{-}10008

This was matching [write_ from some lines much ahead of the nearest [write_ to 10008. This is why tried to filter out such bogus matches using negative lookahead.

/\[write_\_.\{-}10008\([write_\)\@!

This also didn't work for me. Where did I go wrong, or am I thinking in completely wrong direction? Thanks for any help.

Upvotes: 0

Views: 366

Answers (1)

Kent
Kent

Reputation: 195039

I think this is what you are looking for:

/\v\[write_(\_.(\[write_)@!){-}10008

You put the negative look ahead in wrong place.

Upvotes: 1

Related Questions