Community
    • Login

    how to move text to other location in notepad

    Scheduled Pinned Locked Moved Help wanted · · · – – – · · ·
    7 Posts 2 Posters 4.8k 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.
    • Vuvanvui VuiV Offline
      Vuvanvui Vui
      last edited by

      Hi guy! I want to ow to move text to other location in notepad++ with replace or macro
      ex: i have some text:
      <p>Here’s to the crazy ones, the misfits, the rebels, the troublemakers, the round pegs in the square holes… note1 the ones who see things note2 differently </p>
      <fn=1>text aaaaaa</fn>
      <fn=2>text bbbbbb</fn>

      I want to replace or macro to:

      <p>Here’s to the crazy ones, the misfits, the rebels, the troublemakers, the round pegs in the square holes… <fn=1>text aaaaaa</fn> the ones who see things <fn=2>text bbbbbb</fn> differently </p>
      that mean i want move text body in tag fn1 to note1!
      some body help me!!

      1 Reply Last reply Reply Quote -1
      • Vuvanvui VuiV Offline
        Vuvanvui Vui
        last edited by

        somebody help me pls

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

          Hello, @vuvanvui-vui,

          UPDATED 03-07-2018 ( search regex changed in order to match a several digits number ! )

          Not totally sure that it’s what you want to !

          Assuming, for instance, the example text, below, where :

          • The first line contains the note3 and note4 marks

          • The second line contains the note1 and note2 marks

          • The third line contains the note5 and note6 marks

          • Somewhere, afterwards, a line beginning with, at least, 3 equal signs ( Note that this sign must NOT be used, anywhere in the current file. You may choose an other symbol, like -, @, ~, #, /, … )

          • Then, all the <fn=#...#>text ......</fn> replacement marks, in a list, with one per line

          <p>Here’s to the crazy ones, the misfits, the rebels, the troublemakers, the round pegs in the square holes… note3 the ones who see things note4 differently </p>
          
          <p>Here’s to the crazy ones, the misfits, the rebels, the troublemakers, the round pegs in the square holes… note1 the ones who see things note2 differently </p>
          
          <p>Here’s to the crazy ones, the misfits, the rebels, the troublemakers, the round pegs in the square holes… note5 the ones who see things note6 differently </p>
          
          ...
          ...
          
          === Replacement Marks ===
          
          <fn=1>text aaaaaa</fn>
          <fn=2>text bbbbbb</fn>
          <fn=3>text cccccc</fn>
          <fn=4>text dddddd</fn>
          <fn=5>text eeeeee</fn>
          <fn=6>text ffffff</fn>
          

          Then :

          • Open your file in N++ OR just copy / paste all the text, above, in inverse video, in a new tab ( Ctrl + N )

          • Open the Replace dialog ( Ctrl + H )

          • Type in the regex (?-i)\bnote(\d+)\b(?s)(?=.*\R((?-s)<fn=\1>.*))|^===.+ in the Find what: zone

          • Type in the regex ?2\2, in the Replace with: zone

          • Tick the Wrap around option and select the Regular expression search mode

          • Click, once, on the Replace All button ( or several times on the Replace button ! )

          Et voilà ! You should get the following text :

          <p>Here’s to the crazy ones, the misfits, the rebels, the troublemakers, the round pegs in the square holes… <fn=3>text cccccc</fn> the ones who see things <fn=4>text dddddd</fn> differently </p>
          
          <p>Here’s to the crazy ones, the misfits, the rebels, the troublemakers, the round pegs in the square holes… <fn=1>text aaaaaa</fn> the ones who see things <fn=2>text bbbbbb</fn> differently </p>
          
          <p>Here’s to the crazy ones, the misfits, the rebels, the troublemakers, the round pegs in the square holes… <fn=5>text eeeeee</fn> the ones who see things <fn=6>text ffffff</fn> differently </p>
          

          Best Regards,

          guy038

          P.S. :

          Next time, if you would like to, I’ll explain how this regex S/R works :-))

          Vuvanvui VuiV 1 Reply Last reply Reply Quote 1
          • Vuvanvui VuiV Offline
            Vuvanvui Vui @guy038
            last edited by

            @guy038 thanks you verymuch sir!, ;)

            P/S: Next time, if you would like to, I’ll explain how this regex S/R works :-)) (i’m understand)

            1 Reply Last reply Reply Quote 0
            • Vuvanvui VuiV Offline
              Vuvanvui Vui
              last edited by

              hi @guy038 if i want to:
              <p>Here’s to the crazy ones, the misfits, the rebels, the troublemakers, the round pegs in the square holes… note3 the ones who see things note4 differently </p>
              <fn=3>text cccccc</fn>
              <fn=4>text dddddd</fn>
              <p>Here’s to the crazy ones, the misfits, the rebels, the troublemakers, the round pegs in the square holes… note1 the ones who see things note2 differently </p>
              <fn=1>text aaaaaa</fn>
              <fn=2>text bbbbbb</fn>
              <p>Here’s to the crazy ones, the misfits, the rebels, the troublemakers, the round pegs in the square holes… note5 the ones who see things note6 differently </p>
              <fn=5>text eeeeee</fn>
              <fn=6>text ffffff</fn>

              can you help me?

              1 Reply Last reply Reply Quote -1
              • guy038G Offline
                guy038
                last edited by guy038

                Hi, @vuvanvui-vui,

                I’m sorry, but it’s not very clear what you would like to :

                • Are the lines <p>Here’s to........differently </p> consecutive or embedded among other lines ?

                • Are the lines <fn=#>text aaaaaa</fn> located anywhere, in your file or mixed with the <p>Here’s to........differently </p> ones ?


                In other words, could you show us :

                • The text ( or part of it ), what you get, presently, before process

                • The text that you expect to, after process

                It’s always better to work with true material !


                Note that, may be, it won’t be possible to get it with regular expressions, but, ONLY, with a scripting language, as the Lua or Python plugin !

                If your file contents are not confidential, you could, also, send me an e-mail, with your file attached, at :

                Cheers,

                guy038

                1 Reply Last reply Reply Quote 1
                • Vuvanvui VuiV Offline
                  Vuvanvui Vui
                  last edited by

                  thanks @guy038 , I started to really enjoy python, thankyou verymuch :)

                  1 Reply Last reply Reply Quote 0

                  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