Community
    • Login

    Remove CRLF Not Preceded by a Space

    Scheduled Pinned Locked Moved Help wanted · · · – – – · · ·
    3 Posts 2 Posters 2.4k Views
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • Wayne ApratoW
      Wayne Aprato
      last edited by

      I have a text file that contains 10000 records exported from DataPerfect. There are many unwanted CRLFs that I need to remove. Most of the problem CRLFs are NOT preceded by a space. The valid CRLFs are usually preceded by a space.

      Is there a way that I can use the replace function to remove the CRLFs that are NOT preceded by a space?
      Any help is greatly appreciated.

      Scott SumnerS 1 Reply Last reply Reply Quote 0
      • Scott SumnerS
        Scott Sumner @Wayne Aprato
        last edited by

        @Wayne-Aprato

        Any decent text editor has a way of doing what you need and Notepad++ is no exception.

        Invoke the Replace dialog, and then:

        Find-what zone: (?<!\x20)\r\n
        Replace-with zone: make sure this zone has nothing in it
        Search-mode setting: Regular expression
        Action: your choice of Replace or Replace All

        So in essence what the FInd-what formula is doing is finding a CRLF pair (the \r\n part), and then looking at the character immediately preceding. If it is NOT a space character (\x20), then that particular CRLF pair gets replaced (with nothing as that is what is specified in Replace with), otherwise it is left as it is.

        1 Reply Last reply Reply Quote 1
        • Wayne ApratoW
          Wayne Aprato
          last edited by

          Thanks Scott. Much appreciated.

          1 Reply Last reply Reply Quote 0
          • First post
            Last post
          The Community of users of the Notepad++ text editor.
          Powered by NodeBB | Contributors