Reputation: 154
foo = bar
foo = bar
bar = foo
bar = foo asdfghjk
Is there a way to match every foo
that is NOT on the left of an equal sign, so in this case the last two? I've tried:
(foo)([^=])
But that doesn't work. I'm not that good with regex, I don't know what to do from here.
Also, I am trying to pattern match in vim. I don't know if that makes a difference. I am aware the parentheses have to be escaped with \
.
Upvotes: 2
Views: 490
Reputation: 627082
You can use
:g/\vfoo(.*\=)@!/
Vim test:
The g
lobal pattern
\v
- sets the very magic mode to avoid overescapingfoo
- a foo
string(.*\=)@!
- Vim-style classic negative lookahead that means that there can't be a =
after any 0 or more chars (but line break chars) as many as possible.Upvotes: 3