Community
    • Login

    Massive list and massive search and replace?

    Scheduled Pinned Locked Moved Help wanted · · · – – – · · ·
    24 Posts 8 Posters 10.8k 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.
    • nerdyone255N
      nerdyone255
      last edited by

      this script is FANTASTIC.

      i do have a question though- in the final output it prints how many replacements were made, but is there any way to see what the actual replacements were?

      looking into the code i see

      “”" if self.num_repl_made_in_this_file > 0:

                      self.print('replacing "{fw}" with "{rw}" {n} times'.format(
                          fw=find_what, rw=replace_with, n=self.num_repl_made_in_this_file)) """
      

      but i dont see where that would get printed- it doesnt show up in the python console either

      again huge thanks for this one

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

        @nerdyone255 said :

        this script is FANTASTIC.

        Well…glad you like it.

        but i dont see where that would get printed- it doesnt show up in the python console either

        The self.print() function calls are really meant as debug helpers while testing the script. Thus, in the version of the script above, they don’t do anything because the debug variable is set to False. If you change the 0 to a 1 in this line:

        self.debug = True if 0 else False

        or simply change it to:

        self.debug = True

        then the output of the self.print() calls will go to the PythonScript console window. You’ll see the output you indicated you were interested, plus output from other things that happen while the script is running.

        nerdyone255N 1 Reply Last reply Reply Quote 2
        • nerdyone255N
          nerdyone255 @Alan Kilborn
          last edited by

          @Alan-Kilborn perfect!

          1 Reply Last reply Reply Quote 1
          • Alan KilbornA Alan Kilborn referenced this topic on
          • Yurble VươngY
            Yurble Vương @Alan Kilborn
            last edited by PeterJones

            @Alan-Kilborn

            Thanks Alan, it work perfectly, Except one specially for me. Appreciate your help if possible:

            I want to find only within word boundary.


            For example:
            Sentence: You are eating apple. The tree have a lot of apples. all the apples is green.
            apple->cherry
            apples->cherries


            Hence, how can I add in a code to made it change only words start or end a transition from space to non-space character (space, common, dot, quote marks, questions mark…).

            thanks in advance
            Yurble

            Alan KilbornA 1 Reply Last reply Reply Quote 0
            • Alan KilbornA
              Alan Kilborn @Yurble Vương
              last edited by

              @Yurble-Vương said in Massive list and massive search and replace?:

              how can I add in a code to made it change only words start or end a transition from space to non-space character

              You can use \b in the regular expression to insist upon a word boundary; example: \bapple will match have an apple today but will not match have a crabapple today.

              Yurble VươngY 2 Replies Last reply Reply Quote 1
              • Yurble VươngY
                Yurble Vương @Alan Kilborn
                last edited by

                This post is deleted!
                1 Reply Last reply Reply Quote 0
                • Yurble VươngY
                  Yurble Vương @Alan Kilborn
                  last edited by Yurble Vương

                  @Alan-Kilborn

                  Sorry to ask and bother you. I tried to edit your py code as below, but it seems to be a wrong code. Could you advise how to correct:

                  Not work:

                       # FINALLY, the actual replacement!
                                  editor.rereplace('\b'+find_what+'\b', replace_with)
                  

                  Not work 2:

                       # FINALLY, the actual replacement!
                                  editor.rereplace(r'\b'+find_what+'\b', replace_with)
                  
                  Alan KilbornA 1 Reply Last reply Reply Quote 1
                  • Alan KilbornA
                    Alan Kilborn @Yurble Vương
                    last edited by

                    @Yurble-Vương said :

                    Not work 2

                    This should work: editor.rereplace(r'\b'+find_what+r'\b', replace_with)

                    I like how you showed initiative in trying to solve the problem yourself…and you had the right idea, you just didn’t take it far enough.

                    Yurble VươngY 1 Reply Last reply Reply Quote 2
                    • Yurble VươngY
                      Yurble Vương @Alan Kilborn
                      last edited by

                      @Alan-Kilborn

                      Many thanks for help

                      1 Reply Last reply Reply Quote 0
                      • Alan KilbornA Alan Kilborn referenced this topic on
                      • T
                        tszombathy-debaru
                        last edited by

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