Community

    • Login
    • Search
    • Recent
    • Tags
    • Popular
    • Users
    • Groups
    • Search

    Join lines with specific symbol

    Help wanted · · · – – – · · ·
    2
    2
    92
    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.
    • Salamander931
      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 R
        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
        • First post
          Last post
        Copyright © 2014 NodeBB Forums | Contributors