0

I want to find two consecutive non-empty lines.

AAA
BBB

    AAA
BBB

AAA
    BBB

    AAA
    BBB

The file above shows four pairs of consecutive non-empty lines. All of the lines can have trailing white space

I tried ^\s*\S\+\n\s*\S+ But that does not do the job. Moreover, it does not account for trailing spaces. I tried ^\s*\S\+\s*$\n\s*\S+\s*$ too. But no luck again.

So, how do I search for such lines? And it would be great if you could explain your solution.

2

Try this:

/.*\S.*\n.*\S

That finds a line containing at least one non-space character (\S) followed by another line containing at least one non-space character. That assumes that "non-empty" means containing at least one non-space character.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.