tags:

views:

123

answers:

1

I've tried a number of different search patterns:

  • [^=]=[^=] works but only if = is not at the beginning/end and it also matches the sandwiching characters
  • =\@!==\@! seems like it should work because \@! matches nothing but requires a match, but it doesn't (see :help pattern-overview)
  • [^=]\@==[^=]\@= also doesn't but seems like it should

Suggestions?

+5  A: 

Ah hah: =\@<!==\@!

me2
Ahhhhh, it's got eyes!!!
dsimcha
For reference, seems that \@<! should be used on the left of a pattern and \@! should be used on the right. It's not obvious that they form a matched pair, but they do.
me2
FYI, those are `vim`'s version of negative lookbehind and negative lookahead. In most Perl-derived regex flavors your regex would look like this: `(?<!=)=(?!=)`. ref: http://www.regular-expressions.info/lookaround.html
Alan Moore
Can you explain your answer to regex newbies?
Mosh
`\(...\)\@<!` means «not preceded by ...», `\(...\)\@!` means «not followed by ...». These are zero-width matches: they must be matched, but they do not add symbols to the match.
ZyX