• Login
Community
  • Login

How to merge lines in bulk

Scheduled Pinned Locked Moved Help wanted · · · – – – · · ·
9 Posts 5 Posters 1.3k 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.
  • F
    Faisal Alam
    last edited by Faisal Alam Dec 9, 2020, 4:47 PM Dec 9, 2020, 4:45 PM

    Sorry for bad english or if i sound selfish this is my first question here.

    My text:
    3040

    Woodsidi
    5202
    Sivilli Rd
    6406

    W 81 ST
    1853
    Yukon Ct

    What i want:

    3040 Woodsidi
    5202 Sivilli Rd
    6406 W 81 ST
    1853 Yukon Ct

    Please note this is not the only thing, i do have lots of texts in my txt file but i just wanted to fix this one.

    P 1 Reply Last reply Dec 9, 2020, 5:28 PM Reply Quote 0
    • P
      PeterJones @Faisal Alam
      last edited by Dec 9, 2020, 5:28 PM

      @Faisal-Alam ,

      Thank you for the before and after text. (For more hints for crafting even better questions, see the stuff after the ---- line below.)

      If I understand correctly, you want to search for a line that is only a number, followed by 1 or more newlines, followed by a line of text; you want to merge that into the found number followed by a space followed by the found line of text (all one line).

      • FIND = (?-s)^(\d+)\R+
      • REPLACE = $1\x20
      • SEARCH MODE = Regular Expression

      The find puts a 1-or-more-digit number into group#1, making sure it’s starts at the beginning of the line and the match includes the one or more newline characters after that number. The replace uses the contents of group 1 ($1) followed by the space character (\x20: I used that fancy notation because you cannot see the space character at the end of a regex in the forum; you could just type $1 followed by the space character in your REPLACE string as well.)

      I may have assumed too much, or too little. If this isn’t right, you’ll have to give better examples that show more of your edge cases.

      ----

      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 plain text using the </> toolbar button or manual Markdown syntax. 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.

      1 Reply Last reply Reply Quote 3
      • F
        Faisal Alam
        last edited by Dec 10, 2020, 1:57 AM

        Not working :(

        1 Reply Last reply Reply Quote 0
        • T
          Terry R
          last edited by Dec 10, 2020, 2:12 AM

          @Faisal-Alam said in How to merge lines in bulk:

          Not working :(

          You need to re-post your examples, this time selecting the example lines once you have inserted them and click on the </> button above the window you are typing in. This will prevent the possibility of some characters being altered by the posting engine. This was part of @PeterJones comments at the bottom of his post to you.

          1 Reply Last reply Reply Quote 2
          • G
            guy038
            last edited by guy038 Dec 10, 2020, 10:57 AM Dec 10, 2020, 10:39 AM

            @faisal-alam,

            So, in summary:

            • No kind words to @PeterJones who took his time to find a solution for you + precious advice for a quick and precise regex help

            • A tiny answer, of two words, that gives no more relevant information !

            Do you think, really, that you deserve an answer from @PeterJones, @Terry-R, me or others ? You may have no time to lose, but neither do we !

            Please, adopt a constructive attitude and give us some hints. Otherwise, I will make no effort, on my part, to investigate your problem !

            guy038

            F 1 Reply Last reply Dec 11, 2020, 4:33 AM Reply Quote 3
            • A
              Alan Kilborn
              last edited by Dec 10, 2020, 12:26 PM

              @PeterJones solution is working for me.
              Probably for the OP it is PBKAC

              1 Reply Last reply Reply Quote 0
              • F
                Faisal Alam @guy038
                last edited by Dec 11, 2020, 4:33 AM

                @guy038
                Sorry i haven’t checked it afterwards 😬 my sincere apologies to him

                P 1 Reply Last reply Dec 11, 2020, 1:54 PM Reply Quote 0
                • P
                  PeterJones @Faisal Alam
                  last edited by Dec 11, 2020, 1:54 PM

                  This post is deleted!
                  1 Reply Last reply Reply Quote 0
                  • P
                    PeterJones
                    last edited by Dec 11, 2020, 2:00 PM

                    For future readers, the discussion continues in another Topic.

                    (In general, it’s advised that clarifications of the same question be made in the same Topic, but since the discussion continued there, there’s not much we can do about it in this instance.)

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