Omnipresent
Omnipresent

Reputation: 30434

find regex pattern in Vim

some text i dont care about, some_text_I_want,
<bunch of spaces> some_text_I_want,

I want my pattern to match second line, not first line. Basically wherever some_text_I_want, is not preceeded with a ,

Upvotes: 2

Views: 286

Answers (2)

Brian Carper
Brian Carper

Reputation: 73006

A negative lookbehind assertion is straightforward:

\v(,\s*)@<!some_text_I_want

Upvotes: 0

DrAl
DrAl

Reputation: 72726

How about:

\([^ ,]\|^\)\s*some_text_I_want

?

The bit in brackets looks for a character that isn't a space or a comma, or alternatively the start of the line. Then there is an allowance for any spaces and the text you want.

Upvotes: 1

Related Questions