Community
    • Login

    Join lines with specific symbol

    Scheduled Pinned Locked Moved Help wanted · · · – – – · · ·
    2 Posts 2 Posters 1.0k Views 1 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.
    • Salamander931S Offline
      Salamander931
      last edited by

      I have text like this

      678,“Name”,2017
      \n<strong>Country: </strong>UK
      \n<strong>Save:</strong> UN.
      679,“Name”,2019
      \n<strong>Country: </strong>USA
      \n<strong>Save:</strong> UNC.
      \n<strong>Count:</strong> 3.

      And I need to make it look like this

      678,“Name”,2017\n<strong>Country: </strong>UK\n<strong>Save:</strong> UN.
      679,“Name”,2019\n<strong>Country: </strong>USA\n<strong>Save:</strong> UNC.\n<strong>Count:</strong> 3.

      So basically I want to join line that starts with “\n” with previous line and I don’t want to delete this “\n” symbol. Any ideas how to do this?

      1 Reply Last reply Reply Quote 0
      • Terry RT Offline
        Terry R
        last edited by Terry R

        @Salamander931 said in Join lines with specific symbol:

        So basically I want to join line that starts with “\n” with previous line and I don’t want to delete this “\n” symbol. Any ideas how to do this?

        Using a regular expression in the “Replace” function we have:
        Find What:(?-s)\R^(\\n.+)
        Replace With:\1
        So search mode must be regular expression. Click on the “Replace All” button to change the entire file.

        You will see the \\ in the expression because the \ is regarded as a special character, so the additional \ escapes it, or reverts it to a normal character.

        Terry

        PS since you didn’t show the example inside of a black box (read the “read me before posting”) it’s possible this might not work. I suspect you may have leading spaces on some lines.

        1 Reply Last reply Reply Quote 2

        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