Search code examples
notepad++export-to-excelline-breaks

Remove line breaks excluding all before a group of numbers


I have a text file in which I need to remove line breaks, excluding the ones before a group of numbers.

For example, I would like to convert this:

237304||361234295694||360000316633||2021-05-12 18:51:26||Will it fit 123 model
Thanks T 
https://www.xxxxxxx.com 
238367||361234295694||360000316633||2021-05-17 13:38:12||I would like to return some items I bought. 

Into this:

237304||361234295694||360000316633||2021-05-12 18:51:26||Will it fit 123 model Thanks T https://www.xxxxxxx.com 
238367||361234295694||360000316633||2021-05-17 13:38:12||I would like to return some items I bought. 

To be clear, I need the first set of characters on each row to be these numbers you see here "237304" and "238367". They represent ticket numbers, and they are all unique.

I tried using "Join lines" but that removes all line breaks leaving me with one long text file with 1 line. How can I do this automated? The file is very large and it could take me days if I were to do it manually.


Solution

    • Ctrl+H
    • Find what: \R(?!\d)
    • Replace with: A space
    • TICK Wrap around
    • SELECT Regular expression
    • Replace all

    Explanation:

    \R          # any kind of linebreak
    (?!\d)      # negative lookahead, make sure we haven't a digit after
    

    Screenshot (before):

    enter image description here

    Screenshot (after):

    enter image description here