• Login
Community
  • Login

Bookmark, copy spesific lines in notpad++

Scheduled Pinned Locked Moved Help wanted · · · – – – · · ·
11 Posts 3 Posters 871 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.
  • A
    akram duna
    last edited by Jan 29, 2023, 3:31 PM

    Hello

    How can i select or import some specific combos in a txt file notpad++ ,The txt file is like

    testxx:textxx
    <------------>
    Test #1: 0
    Test #2: 3
    Test #3: 0
    <------------>
    test1:test1
    <------------>
    *********
    <------------>
    test22:test22
    <------------>
    *********
    <------------>
    testxx2:testxx2
    <------------>
    Test #1: 0
    Test #2: 1
    Test #3: 4
    <------------>
    

    I want to select or copy combos before this suffix

    <------------>
    Test #1: 0
    Test #2: 1
    Test #3: 4
    <------------>
    Test #1: 0
    Test #2: 1
    Test #3: 4
    <------------>
    
    

    btw the numbers after Test #1 Test #2 Test #3 are always different

    lLike in the example file , i want to import these combos

    testxx:textxx
    testxx2:testxx2
    

    Thank you

    1 Reply Last reply Reply Quote 0
    • G
      guy038
      last edited by guy038 Jan 29, 2023, 5:05 PM Jan 29, 2023, 4:06 PM

      Hello, @akram-duna and All,

      One possible method would be to use regular expressions !


      • Open the Mark dialog ( Ctrl + M )

      • Type in (?x-s) ^ testxx .+ \R < -+ > \R \K (?s: .+? ) (?= \R ^ < -+ > ) in the Find what: zone

      • Untick all the box options

      • Click the 3 options Bookmark line, Purge for each search and Wrap around

      • Select the Regular expression search mode

      • Click on the Mark All button

      • Click on the Copy Mark Text button

      • Open a new tab ( Ctrl + N )

      • Paste the copied text ( Ctrl + V )

      Here your are !

      Note that any line, made of only four dashes, between your blocks, are generated by the Copy Marked Text feature itself !

      Best Regards,

      guy038

      A 1 Reply Last reply Jan 29, 2023, 4:14 PM Reply Quote 2
      • A
        akram duna @guy038
        last edited by Jan 29, 2023, 4:14 PM

        @guy038
        Hi mate thanks for your help but the

        testxx:textxx
        testxx2:testxx2
        

        are just examples the origin file contains a lot of different data , that main idea is to copy them using these

        <------------>
        Test #1: 0
        Test #2: 1
        Test #3: 4
        <------------>
        
        1 Reply Last reply Reply Quote 0
        • G
          guy038
          last edited by guy038 Jan 29, 2023, 4:21 PM Jan 29, 2023, 4:18 PM

          Hi, @akram-duna,

          Are the blocks to copy contain, at least, two successive lines ?

          BR

          guy038

          1 Reply Last reply Reply Quote 1
          • G
            guy038
            last edited by guy038 Jan 29, 2023, 4:28 PM Jan 29, 2023, 4:27 PM

            Hi, @akram-duna,

            Or are all the lines to copy begin with the string Test ?

            BR

            guy038

            A 1 Reply Last reply Jan 29, 2023, 4:44 PM Reply Quote 1
            • A
              akram duna @guy038
              last edited by Jan 29, 2023, 4:44 PM

              @guy038

              the repeated sentence in my file are

              <------------>
              Test #1:
              Test #2:
              Test #3: 
              <------------>
              
              1 Reply Last reply Reply Quote 0
              • G
                guy038
                last edited by guy038 Jan 29, 2023, 5:02 PM Jan 29, 2023, 4:48 PM

                Hi, @akram-duna and All,

                Could you try this Mark regex ?

                (?x-si) < -+ > \R \K (?: Test \x20 .+ \R? )+ (?= \R ^ < -+ > )

                Remark : You do not even need to tick the Bookmark line option !

                If OK, I’ll explain you how this regex works !

                Cheers,

                guy038

                A 1 Reply Last reply Jan 29, 2023, 6:50 PM Reply Quote 2
                • A
                  akram duna @guy038
                  last edited by Jan 29, 2023, 6:50 PM

                  Hi @guy038

                  I tried it and it mark

                  Test #1: 0
                  Test #2: 3
                  Test #3: 0
                  
                  Test #1: 0
                  Test #2: 1
                  Test #3: 4
                  

                  now how to change it to mark

                  testxx:textxx
                  testxx2:testxx2
                  
                  P 1 Reply Last reply Jan 29, 2023, 9:38 PM Reply Quote 0
                  • P
                    PeterJones @akram duna
                    last edited by Jan 29, 2023, 9:38 PM

                    @akram-duna

                    You’re not doing a great job of describing what you want, and you seem to be changing your spec every time you ask the question. Guy has done his best to guess what you mean, and has done a reasonable job; I will usually try to guess, but with your problem desciption, I cannot tell at all what you want (so i cannot offer any suggestions).

                    Please do a better job of defining your desires, so you get one last answer, and then understand that you are expected to learn from what we share, and figure out how to customize it yourself, and not just expect us to do your homework/job for you.

                    ----

                    Useful References

                    • Please Read Before Posting
                    • Template for Search/Replace Questions
                    • Formatting Forum Posts
                    • Notepad++ Online User Manual: Searching/Regex
                    • FAQ: Where to find other regular expressions (regex) documentation

                    ----

                    Please note: This Community Forum is not a data transformation service; you should not expect to be able to always say “I have data like X and want it to look like Y” and have us do all the work for you. If you are new to the Forum, and new to regular expressions, we will often give help on the first one or two data-transformation questions, especially if they are well-asked and you show a willingness to learn; and we will point you to the documentation where you can learn how to do the data transformations for yourself in the future. But if you repeatedly ask us to do your work for you, you will find that the patience of usually-helpful Community members wears thin. The best way to learn regular expressions is by experimenting with them yourself, and getting a feel for how they work; having us spoon-feed you the answers without you putting in the effort doesn’t help you in the long term and is uninteresting and annoying for us.

                    1 Reply Last reply Reply Quote 0
                    • G
                      guy038
                      last edited by guy038 Jan 29, 2023, 11:06 PM Jan 29, 2023, 10:54 PM

                      Hello, @akram-duna and All,

                      Ah… OK ! Of course, you could try that regex :

                      (?x-si) ^ .+ \R < -+ > \R (?: Test \x20 .+ \R? )+ (?= \R ^ < -+ > )

                      But the main problem is not solved. We need to know how your present data is organized !


                      Could you provide us, a reasonable amount of your real text ( I mean, between 50 and 150 lines ) which recapitulates all ( or almost all ) the possible cases of your INPUT data :

                      INPUT

                      testxx:textxx
                      <------------>
                      Test #1: 0
                      Test #2: 3
                      Test #3: 0
                      <------------>
                      ....
                      ....
                      ....
                      ....
                      

                      And, starting with that INPUT data, could you show us the OUTPUT text that you expect to :

                      OUTPUT

                      ...
                      ...
                      ...
                      

                      BR

                      guy038

                      A 1 Reply Last reply Jan 29, 2023, 11:25 PM Reply Quote 1
                      • A
                        akram duna @guy038
                        last edited by Jan 29, 2023, 11:25 PM

                        @guy038
                        Thanks a lot your the best I solved my problem with our help, and sorry for my bad description its just about a language issue :D

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