Community
    • Login

    Remove CRLF Not Preceded by a Space

    Scheduled Pinned Locked Moved Help wanted · · · – – – · · ·
    3 Posts 2 Posters 2.8k Views 2 Watching
    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 Offline
      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 Offline
        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 Offline
          Wayne Aprato
          last edited by

          Thanks Scott. Much appreciated.

          1 Reply Last reply Reply Quote 0

          Hello! It looks like you're interested in this conversation, but you don't have an account yet.

          Getting fed up of having to scroll through the same posts each visit? When you register for an account, you'll always come back to exactly where you were before, and choose to be notified of new replies (either via email, or push notification). You'll also be able to save bookmarks and upvote posts to show your appreciation to other community members.

          With your input, this post could be even better 💗

          Register Login
          • First post
            Last post
          The Community of users of the Notepad++ text editor.
          Powered by NodeBB | Contributors