How to merge lines in bulk

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

    My text:

    Sivilli Rd

    W 81 ST
    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.

  • @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.

  • Not working :(

  • @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.

  • @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 !


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

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

  • This post is deleted!

  • 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.)

Log in to reply