Search code examples
replacefindnotepad++newline

Inserting CRLF into a string sequence in Notepad ++


I have a text file that has incorrectly placed line breaks. The position where the line break should be placed goes like this ...xxxXxxx... (every x is a character [a-z] with the capital X being a capital character [a-z]. I want to place the CRLF in front of the capital letter. How do I do it? I can find all these sequences by Find what: [a-z][A-Z][a-z] (match case 1) but I don't know what to type in the Replace with field to keep the original text.


Solution

    • Ctrl+H
    • Find what: (?<=\p{lower})(?=\p{upper})
    • Replace with: \r\n
    • CHECK Match case
    • CHECK Wrap around
    • CHECK Regular expression
    • Replace all

    Explanation:

    (?<=\p{lower})  # positive lookbehind, make sure we have a lowercase letter before
    (?=\p{upper})   # positive lookahead, make sure we have an uppercase letter after
    

    Replacement:

    \r\n            # CRLF
    

    Screenshot (before):

    enter image description here

    Screenshot (after):

    enter image description here