Search code examples
notepad++

Notepad++ How to delete carriage return in lines without full stops only


I have documents that contain carriage returns in the middle of sentences, like this:

Were there any connections? Or
was all of it

I have found a regex for finding these lines (Find: \w$) and I can insert a full stop if I want (Replace: $0.) but what do I do to insert a space and remove the carriage return/delete it instead so it becomes this:

Were there any connections? Or was all of it

I have a lot of these to replace so it would be helpful to get a replace command that takes care of all of them.

Is there a way to do this?


Solution

    • Ctrl+H
    • Find what: (?<=\w)\R(?=\w)
    • Replace with: A space
    • CHECK Wrap around
    • CHECK Regular expression
    • Replace all

    Explanation:

    (?<=\w)     # positive lookbehind, make sure we have a word character before
    \R          # any kind of linebreak
    (?=\w)      # positive lookbahead, make sure we have a word character after
    

    Screenshot (before):

    enter image description here

    Screenshot (after):

    enter image description here