petobens
petobens

Reputation: 1390

Vim regex: match line except pattern

I have the following two lines:

test.tex|42 error| Undefined control sequence
test.tex|43 error| Undefined control sequenceFAILURE

I want a regex that matches "Undefined control sequence" in both lines (thus ignoring the FAILURE part in the second line). I tried with

/^|\d\+ error|\s\zs.*

but that obviously highlights FAILURE too. I suppose I must use a negative lookahead but I'm using it wrong since the following doesn't work

/^|\d\+ error|\s\zs.*\(FAILURE\)\@!

EDIT: The "Undefined control sequence" is just a type of error. The generic structure of the lines is

 file|number error| Error message

I want a generic regex that matches only the error message that sometimes ends as

Error messsageFAILURE

I want to ignore the "FAILURE" part and just get the "Error message"

Upvotes: 0

Views: 193

Answers (2)

Kent
Kent

Reputation: 195029

for your question, /Undefined control sequence will work exactly what you wanted.

If you want to have some dynamic matching, you could try:

\verror\|\s\zs.{-}\ze(FAILURE|$)

Upvotes: 1

Marco Baldelli
Marco Baldelli

Reputation: 3728

The pattern /Undefined control sequence will match both lines, while the pattern /Undefined control sequence\> will only match the first line since \> matches the end of a word.

Upvotes: 0

Related Questions