Find line that starts with expression negation

4

I have a text file with many lines. Is it possible for me to find the first line that does not match regex ? Example, I want to make a regex that shows me the first line that does not start with BOLO

BOLO
BOLO
CHOCOLATE

I'm using sublime , meaning my regex has to find the word CHOCOLATE. Remembering that my regex needs to be on top of the word CAUSE because I do not know which line comes after.

    
asked by anonymous 24.08.2017 / 15:32

1 answer

4

Combine the anchor ( ^ ) with the negative lookhead ( ?! ) this will identify lines that do not start with BOLO

^(?!BOLO)

Text:

BOLO
BOLO
CHOCOLATE
RECEITAS BOLO

This example matches the last two lines.

See working at REGEX101

    
24.08.2017 / 15:38