Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Vim find pattern unless it matches

Tags:

vim

search

I have a space delimited set of hex values and want to find /[0-9a-f]\{2\} unless the value is 00. For example, if the buffer is

00 00 00 00 18 00 00 00

the pattern should match the 18 but not the white space or the 00.

like image 239
ctuffli Avatar asked Mar 14 '26 02:03

ctuffli


1 Answers

This can be done with the following regular expression:

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

Explanation:

  • \x: hex digit: [0-9A-Fa-f]
  • \{2}: matches two of the preceding atom
  • \(00\): an atom containing 00
  • \@<! nothing, requires NO match behind

For more information, see:

  • :help pattern.txt
like image 176
Johnsyweb Avatar answered Mar 17 '26 02:03

Johnsyweb



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!