-2

I have a list of over 200,000 lines. It is mixed with the majority of lines starting with 12 digit number, and the remainder starting with any character. I want to keep all the lines that have a 12 digit number at the beginning, and those that do not, I want to backspace to remove the CRLF, and add a space.

Example:

200000000000,##x,Free textCRLR
         - I have the following, xxx, yyy,zzz

What I want is a complete list, where the any line not starting with 200000000000 the previous CRLR is removed, and a space is added to the front of the line.

I attempted to find the beginning of the lines without numbers using ^. which returned 3643 lines that started with -. I used \l which only removed the leading -.

2
  • always format printouts as code for readability ... did it for you
    – jsotola
    Commented Jun 3 at 18:09
  • did you mean CRLF?
    – jsotola
    Commented Jun 3 at 18:19

1 Answer 1

0

You can use a negative look-head to assert that a linebreak is not followed by 12 digits, and in that case replace the linebreak with a space:

Find what: \R(?!\d{12})
Replace with: (one space)
Search mode:
⦿ Regular expression

Replace All

3
  • Sorry for the long delay.
    – M S
    Commented Jun 11 at 11:16
  • I used (\R)(?!\d{12},18Y,) w/regular expression & matches newline checked. The table delimiter was changed from a comma separated to a pipe separated table. I adjusted the expression to (\R)(?!\d{12}\|18Y\|) to accommodate the new delimiter & then replaced w/a single space. 18Y is the value in the second column, the third column can be any value. The expression validates the column structure for each line, if the line does not match the CR LF is replaced w/a single space. It could also be just nothing, which would clear the CR LF as well w/o adding a space. Thanks for the help.
    – M S
    Commented Jun 11 at 11:26
  • I'm not sure what to make of your comment. If there is still a problem, then please update your question with the new information (the different format, delimiter, ...etc).
    – trincot
    Commented Jun 11 at 14:36

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