Community
    • Login

    special search and replace in Notepad++

    Scheduled Pinned Locked Moved Help wanted · · · – – – · · ·
    5 Posts 3 Posters 518 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.
    • Thomas KlinghanT
      Thomas Klinghan
      last edited by

      Hi. I am trying to remove the line \n in Notepad++in some lines and replace it with a tab \t or a space. In the pictures it is (visually) better explained.

      The data consists of variables with point name Y X H (4 elements). Now the \n up to the 4th element should be replaced by a \t or a blank. Then a \n should create a new variable in a line.
      So convert the first 4 lines into one line and then repeat the loop.

      Input Data
      before.JPG
      Output Data
      after.JPG

      PeterJonesP Alan KilbornA 2 Replies Last reply Reply Quote 0
      • PeterJonesP
        PeterJones @Thomas Klinghan
        last edited by

        @Thomas-Klinghan

        FIND = (?-s)(^.*$)\R(^.*$)\R(^.*$)\R(^.*$)
        REPLACE = $1 $2 $3 $4
        SEARCH MODE = regular expression
        REPLACE ALL

        ----

        Do you want regex search/replace help? Then please be patient and polite, show some effort, and be willing to learn; answer questions and requests for clarification that are made of you. All example text should be marked as literal text using the </> toolbar button or manual formatting commands.

        To make regex in red (and so they keep their special characters like *), use backticks, like `^.*?blah.*?\z`. Screenshots can be pasted from the clipboard to your post using Ctrl+V to show graphical items, but any text should be included as literal text in your post so we can easily copy/paste your data.

        Show the data you have and the text you want to get from that data; include examples of things that should match and be transformed, and things that don’t match and should be left alone; show edge cases and make sure you examples are as varied as your real data. Show the regex you already tried, and why you thought it should work; tell us what’s wrong with what you do get.

        Read the official NPP Searching / Regex docs and the forum’s Regular Expression FAQ. If you follow these guidelines, you’re much more likely to get helpful replies that solve your problem in the shortest number of tries.

        Thomas KlinghanT 1 Reply Last reply Reply Quote 1
        • Alan KilbornA
          Alan Kilborn @Thomas Klinghan
          last edited by

          @Thomas-Klinghan said in special search and replace in Notepad++:

          remove the line \n

          Also, be careful in what you are talking/thinking about.
          Your file shows CRLF line-endings and yet you talk about \n.
          You should talk about \r\n because that is what CRLF means.

          If you had manipulated just the \n in your file, it would be “corrupt” because there would be only CR on your line-endings, or worse, a mismash of CR and CRLF line-endings.

          Thomas KlinghanT 1 Reply Last reply Reply Quote 1
          • Thomas KlinghanT
            Thomas Klinghan @PeterJones
            last edited by

            @PeterJones
            Hello PeterJones
            Thank you for your quick and helpful reply. I will formulate my questions better and present them better in the future.
            Many greetings
            Thomas

            1 Reply Last reply Reply Quote 0
            • Thomas KlinghanT
              Thomas Klinghan @Alan Kilborn
              last edited by

              @Alan-Kilborn
              Hello Alan Kilborn,
              Thanks for your tips.

              Best regards
              Thomas

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