You cannot sequentially filter the matches like in the shell, so you need to use advanced regular expression features to combine both into a single one.
Basically, you need to assert a non-match of 666
at the match position. That's achieved with the \@!
atom (in other regular expression dialects, that's often written as (?!...)
):
/\%(\d*666\d*\)\@!\<\d\+\>
Note: If you want to only exclude 666
, but not 6666
etc. you need to specify \<666\>
instead in the first part.
I've used \d
instead of [0-9]
; you can further strip down the \
use with the \v
"very magic" modifier:
/\v(\d*666\d*)@!<\d+>