Community

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

    Move character to end of previous line

    Help wanted · · · – – – · · ·
    2
    3
    381
    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.
    • Darren Brown
      Darren Brown last edited by

      Hi. I’m trying to move the pipe on the new line to the end of the previous line, for example -

      233307|35|ABCD|00001111|01/03/2016|||n|n|AB/123456
      |
      233307|36|ABCD|00002222|01/03/2016|||n|n|AB/123456
      |
      233307|37|DCBAL|00003333|01/03/2016|||n|n||
      

      to -

      233307|35|ABCD|00001111|01/03/2016|||n|n|AB/123456|
      233307|36|ABCD|00002222|01/03/2016|||n|n|AB/123456|
      233307|37|DCBAL|00003333|01/03/2016|||n|n||
      

      I can search for the pipe at the start of a new line with ^\s*| but can’t figure out what syntax to use for the replace to move it up to the end of the previous line. Any help would be greatly appreciated. Thanks

      gerdb42 1 Reply Last reply Reply Quote 0
      • gerdb42
        gerdb42 @Darren Brown last edited by

        @darren-brown
        You need to modify your regex to include the preceding line break: \R\s*\|$. If you replace this with | you will get your desired result. Note that I also escaped the | since it has special meaning in regexes. This is a quick-and-dirty shot, there are more elaborate approaches.

        Darren Brown 1 Reply Last reply Reply Quote 2
        • Darren Brown
          Darren Brown @gerdb42 last edited by

          @gerdb42 said in Move character to end of previous line:

          \R\s*|$

          Brilliant, I’ve just tested and it works perfectly. Thanks for the quick response.

          1 Reply Last reply Reply Quote 0
          • First post
            Last post
          Copyright © 2014 NodeBB Forums | Contributors