Community
    • Login

    How to I move a line with Specific character

    Scheduled Pinned Locked Moved Help wanted · · · – – – · · ·
    5 Posts 2 Posters 1.0k Views
    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.
    • Jovan PrlicJ
      Jovan Prlic
      last edited by Jovan Prlic

      Hey, exemple:

      thisisatestaskldjsalk
      SPECIFICCHARACTER%

      So I want it to be:
      thisisatestaskldjsalkSPECIFICCHARACTER%

      Now this repeats multiple times in the notepad but not all the times so I obviously cant just move them all by one line, after moving that line with specific character on the line above it, I want to mark it and delete it because I don’t need that line.

      How do I do it?

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

        @Jovan-Prlic said in How to I move a line with Specific character:

        How do I do it?

        Firstly I’d say you need to provide better examples. Secondly when providing the examples please include enough lines of data that we get a good idea what your needs are. And to really give us enough data to work on, show us the “after” view of the same example so we know what you want at the end.

        To provide examples, when you are typing in the window, use the </> button immediately above the window around the examples so they appear in a black box and thus the interpreter (which you are typing in) will not “adjust/change” the data.

        Currently at the moment I think you have a line of text, followed by another line perhaps containing a “specific character”. Is this character all by itself on a line or amongst other characters? Once these 2 lines are found you mention about combining them and then deleting the combined line. If my assumptions of your problem are right we can skip the combining of the lines and just delete both lines as they stand.

        Terry

        Jovan PrlicJ 1 Reply Last reply Reply Quote 2
        • Jovan PrlicJ
          Jovan Prlic @Terry R
          last edited by Jovan Prlic

          Here is a better example

          This text contains random letters Specific Character
          
          This text contains random letters
          
          This text contains random letters
          
          This text contains random letters
          Specific Character
          

          Whereas I want it to be like this:

          This text contains random letters Specific Character
          
          This text contains random letters
          
          This text contains random letters
          
          This text contains random letters Specific Character
          

          I can’t just remove something that contains a random letter because then I would delete lines I don’t want to delete.

          Therefore, I need to move this Specific Character, let’s make it a * to the lines above, then bookmark it and delete that line.

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

            @Jovan-Prlic said in How to I move a line with Specific character:

            Whereas I want it to be like this:

            Thanks for putting the example inside the black box, although it still hasn’t given me much to work with. It does appear though that your “specific character” is on a line all by itself.

            So as an example I used the below to test my regular expression. The # is the specific character in the test.

            A Cd Eg G H Ik
            #
            A Cdx Eg G H Ikghj
            $
            

            The result will be as below

            A Cdx Eg G H Ikghj
            $
            

            as the $ is NOT a “specific character”.

            Using the Replace function we have:
            Find What:(?-s)^.+\R#\R?
            Replace With: leave this field empty!

            So as this is a regular expression the search mode MUST be “regular expression” and please have wrap around ticked. It is preferable to have the cursor in the very first position of the file, otherwise it might miss the first 2 lines if they are to be removed.

            Note I haven’t combined the 2 lines, that is NOT necessary. It works by looking at both lines and using the 2nd line as the determination on whether to remove or not both lines. Note the way to remove something is to NOT have anything typed into the “Replace With” field of the function.

            You will need to replace the # with your specific character. Be aware some characters such as ()*^${}[]| and others have special meaning. If any of these are to be used you need to type the \ character in front so the character is taken as being a literal character.

            Terry

            Jovan PrlicJ 1 Reply Last reply Reply Quote 3
            • Jovan PrlicJ
              Jovan Prlic @Terry R
              last edited by

              @Terry-R said in How to I move a line with Specific character:

              (?-s)^.+\R#\R?

              It worked, THANK YOU SO MUCH!!

              1 Reply Last reply Reply Quote 1
              • First post
                Last post
              The Community of users of the Notepad++ text editor.
              Powered by NodeBB | Contributors