Find lines not starting with " in Notepad++

RegexNotepad++

Regex Problem Overview


I try to verify a CSV file where we had problems with line breaks.

I want to find all lines not starting with a ".

I am trying with /!^"/gim but the ! negation is not working.

How can I negate /^"/gim properly?

Regex Solutions


Solution 1 - Regex

In regex, the ! does not mean negation; instead, you want to negate a character set with [^"]. The brackets, [], denote a character set and if it starts with a ^ that means "not this character set".

So, if you wanted to match things that are not double-quotes, you would use [^"]; if you don't want to match any quotes, you could use [^"'], etc.

With Notepad++, you should be able to search with the following to find lines that don't start with the " character:

^[^"]

If you want to highlight the full line, use:

^[^"].*

Solution 2 - Regex

In Notepad++ you can use the very usefull negative lookahead

In your case you can try the following:

^(?!")

If you want to match wholes lines add .+ or .{1,7} or anything e.g.:

^(?!").*

will also match empty lines.

Explanation part

^ line start

(?!regexp) negative lookahead part: this means that if the regexp match, the result will not be shown

Solution 3 - Regex

Step 1 - Match lines. Find dialog > Mark tab, you can bookmark lines that match.

Step 2 - Remove lines bookmarked OR Remove lines not bookmarked. Search > Bookmark > Remove Unmarked Lines or Remove Bookmarked lines

Attributions

All content for this solution is sourced from the original question on Stackoverflow.

The content on this page is licensed under the Attribution-ShareAlike 4.0 International (CC BY-SA 4.0) license.

Content TypeOriginal AuthorOriginal Content on Stackoverflow
QuestionDaniel W.View Question on Stackoverflow
Solution 1 - RegexnewfurnitureyView Answer on Stackoverflow
Solution 2 - RegexBoopView Answer on Stackoverflow
Solution 3 - RegexGauravView Answer on Stackoverflow