• Login
Community
  • Login

how to move text to other location in notepad

Scheduled Pinned Locked Moved Help wanted · · · – – – · · ·
7 Posts 2 Posters 4.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.
  • V
    Vuvanvui Vui
    last edited by Mar 3, 2018, 2:55 PM

    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
    • V
      Vuvanvui Vui
      last edited by Mar 4, 2018, 2:28 PM

      somebody help me pls

      1 Reply Last reply Reply Quote 0
      • G
        guy038
        last edited by guy038 Mar 7, 2018, 8:31 PM Mar 4, 2018, 4:58 PM

        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 :-))

        V 1 Reply Last reply Mar 5, 2018, 1:29 AM Reply Quote 1
        • V
          Vuvanvui Vui @guy038
          last edited by Mar 5, 2018, 1:29 AM

          @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
          • V
            Vuvanvui Vui
            last edited by Mar 5, 2018, 3:26 AM

            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
            • G
              guy038
              last edited by guy038 Jun 2, 2021, 10:14 PM Mar 5, 2018, 10:25 AM

              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
              • V
                Vuvanvui Vui
                last edited by Mar 7, 2018, 1:26 PM

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

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