Regex to find any lines that do NOT have a specific number of a character

Eko means use bookmarking feature of the Mark command to match the lines you aren’t interested in finding, then invert the bookmarks (see the Search > Bookmarks menu) to get the lines you are interested in.

Was removing the escaping of the | inside the [ and ] intentional? Yes, I suppose, since it has no special meaning there and doesn’t need escaping.

don’t understand why there is a need to make sure that a line does not start with a pipe

I think that with this type of data, fields could be empty, thus if the first field is empty a line would start with a pipe? But, is the regex really saying what I think you implied? I’m saying “not pipe” not just at the start of a line, but for in between fields as well. And I’m only doing it this way because your original attempt using a . expression fails (for some odd and as yet unknown reason). I think I’m getting confused.

A repeated capturing group will only capture the last iteration. Put a capturing group around the repeated group to capture all iterations or use a non-capturing group instead if you’re not interested in the data.

I generated with the test data of @Ekopalypse a file of 146545 lines and did that what I’ve suggested above - I got the expected result.

Be sure that the pipe character in your file is really a pipe character (code 124). There is another one (code 166 in Windows-1252 character encoding) which looks nearly identical:

Pipe character: |
The other one: ¦

Yup - they’re pipes.

Here is a good sample of what I’m working with. Lines 1, 9, 10, 11, 16 thru 20 and 36, 37 are single-line records with 9 pipes and 10 columns. Lines 2 thru 8 are one record and together have 9 pipes/10 cols. Similarly, lines 12 through 15 are a single record, and lines 21 thru 35 are a single record.

My bad. I didn’t give you all of the details of what I’m working with.

find: ^(?>.*?\|){9}(?!.*?\|) does not make that assumption.

This works.

So at this point what I’d need to do, ideally, is to do a Find/Replace, finding all of the new line/line feed characters - only in those now-bookmarked lines - and replace them with some other character (spaces, dummy chars, whatever) to get each of those records to be on one line. Can I do a find/replace on just the bookmarked lines? Or perhaps, instead of the multi-step approach, is there a way to do this on the Replace tab, entering a regex in the Find what box that finds those lines and just replace the new line characters with dummy characters in one step?

Well, if I copy and paste your “lorem ipsum” data (above) into a new tab and then run my regex (above) on it, I get lines with exactly 9 pipes redmarked, which I thought was the goal (or the inverse of the goal):

…finding all of the new line/line feed characters - only in those now-bookmarked lines - and replace them with some other character (spaces, dummy chars, whatever) to get each of those records to be on one line