Community

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

    ADD A LINE AT THE END

    General Discussion
    3
    5
    2648
    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.
    • Memole1990
      Memole1990 last edited by

      Hello, I am novice to NotePad.

      I would need to add a new line of text after certain lines already present (not all of them).

      I tried with:
      Find what: $
      Replace with: \r

      But in this way he adds a new line to me at the end of all the lines already present.

      How could I do that? Thank you very much!

      Alan Kilborn 1 Reply Last reply Reply Quote 0
      • Alan Kilborn
        Alan Kilborn @Memole1990 last edited by

        @memytim93

        Well you’d have to start by specifying how to identify these “certain lines already present”, i.e., what makes them special? There has to be a pattern to it otherwise it can’t be done.

        1 Reply Last reply Reply Quote 1
        • guy038
          guy038 last edited by guy038

          Hello, @memytim19 and All,

          Well, it depends on the location where you want to insert this new line :

          • If you want to insert this new line at the very end of current file :

            • SEARCH \z

            • REPLACE \r\n

          • If you vant to insert this new line after the Nth first lines of current file

            • SEARCH (?-s)\A((?:.*\R){N})

            • REPLACE \1\r\n

          • If you want to insert this new line after the line ( or each line ) containing the named string String

            • SEARCH (?-s)(?<=String)(.*\R)

            • REPLACE \1\r\n


          For instance, given this INPUT text :

          This is a
          small example
          of text
          to test the
          regexes
          Hope this test will
          be OK
          

          The first regex S/R would produce :

          This is a
          small example
          of text
          to test the
          regexes
          Hope this test will
          be OK
          
          

          The regex S/R :

          • SEARCH (?-s)\A((?:.*\R){5})

          • REPLACE \1\r\n

          gives the following OUTPUT text :

          This is a
          small example
          of text
          to test the
          regexes
          
          Hope this test will
          be OK
          

          and, finally, the regex S/R :

          • SEARCH (?-s)(?<=test)(.*\R)

          • REPLACE \1\r\n

          would return :

          This is a
          small example
          of text
          to test the
          
          regexes
          Hope this test will
          
          be OK
          

          Best Regards,

          guy038

          P.S. :

          Of course, select the Regular expression search mode and tick the Wrap around option !

          Memole1990 1 Reply Last reply Reply Quote 2
          • Memole1990
            Memole1990 @guy038 last edited by

            @guy038 Thank you very much, it’s perfect, I still have a lot to learn

            1 Reply Last reply Reply Quote 0
            • guy038
              guy038 last edited by guy038

              Hi, @memytim19,

              Just look here for documentation

              BR

              guy038

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