Vim find the pattern if it doesn't match

I have a space with hex separators and you want to find /[0-9a-f]\{2\}if the value is not equal 00. For example, if the buffer

00 00 00 00 18 00 00 00

the pattern should match 18, but not a space or 00.

+3
source share
1 answer

This can be done with the following regular expression:

\x\{2}\(00\)\@<!

Explanation:

  • \x: hexadecimal digit: [0-9A-Fa-f]
  • \{2}: matches the previous two atoms
  • \(00\): atom containing 00
  • \@<! nothing for him no match

For more information see

+4
source

All Articles