Notepad++, replace “x” with a value from a listFind and Replace several several different values all at...

Is it possible to run Internet Explorer on OS X El Capitan?

Is it inappropriate for a student to attend their mentor's dissertation defense?

Should I tell management that I intend to leave due to bad software development practices?

Why is Collection not simply treated as Collection<?>

Is the Joker left-handed?

How much of data wrangling is a data scientist's job?

Would Slavery Reparations be considered Bills of Attainder and hence Illegal?

Why doesn't H₄O²⁺ exist?

Why is the 'in' operator throwing an error with a string literal instead of logging false?

Today is the Center

Doing something right before you need it - expression for this?

Fully-Firstable Anagram Sets

What is the most common color to indicate the input-field is disabled?

Why "Having chlorophyll without photosynthesis is actually very dangerous" and "like living with a bomb"?

Why are electrically insulating heatsinks so rare? Is it just cost?

Were any external disk drives stacked vertically?

How do conventional missiles fly?

Why does Kotter return in Welcome Back Kotter

How to model explosives?

Facing a paradox: Earnshaw's theorem in one dimension

Is it unprofessional to ask if a job posting on GlassDoor is real?

Infinite Abelian subgroup of infinite non Abelian group example

Stopping power of mountain vs road bike

Brothers & sisters



Notepad++, replace “x” with a value from a list


Find and Replace several several different values all at onceHow do I add “input” to my macro, to replace text in Notepad++?Regex replace with Notepad++Remove CR LF for all lines that are not followed by a specific numberNotepad ++ find and replace issueNotepad++ replace a random value with blankNotepad++ RegEx Find and replace with 2 variablesHow to remove all top level domain names using Notepad++Replace Multiple Instances of Same Line with Only One Instance?Find/Replace with changing value?






.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty{ height:90px;width:728px;box-sizing:border-box;
}







1















Basically what the title says, let me make an example.



this=X
that=XXX
those=XX


I want to randomly replace X with a value from a list for example, (1, 2 or 3), so that it becomes:



this=2
that=312
those=32


Note that I would prefer that there are no repetitions in the strings, although I can repair that later, if necessary.










share|improve this question































    1















    Basically what the title says, let me make an example.



    this=X
    that=XXX
    those=XX


    I want to randomly replace X with a value from a list for example, (1, 2 or 3), so that it becomes:



    this=2
    that=312
    those=32


    Note that I would prefer that there are no repetitions in the strings, although I can repair that later, if necessary.










    share|improve this question



























      1












      1








      1








      Basically what the title says, let me make an example.



      this=X
      that=XXX
      those=XX


      I want to randomly replace X with a value from a list for example, (1, 2 or 3), so that it becomes:



      this=2
      that=312
      those=32


      Note that I would prefer that there are no repetitions in the strings, although I can repair that later, if necessary.










      share|improve this question
















      Basically what the title says, let me make an example.



      this=X
      that=XXX
      those=XX


      I want to randomly replace X with a value from a list for example, (1, 2 or 3), so that it becomes:



      this=2
      that=312
      those=32


      Note that I would prefer that there are no repetitions in the strings, although I can repair that later, if necessary.







      notepad++






      share|improve this question















      share|improve this question













      share|improve this question




      share|improve this question








      edited Jul 30 '16 at 17:23









      DavidPostill

      108k27235270




      108k27235270










      asked Jul 30 '16 at 17:06









      AnotheroneAnotherone

      62




      62






















          2 Answers
          2






          active

          oldest

          votes


















          0














          I want to randomly replace X with a value from a list



          This is not possible using built in Notepad++ functionality.



          You could write a script to do it.



          There is a python script plugin for Notepad++:




          Python Script for Notepad++




          • Full programmatic access to Notepad++ features and menus

          • Full programmatic access to all of Scintilla features

          • Call other plugin menu items

          • Assign menu items, shortcuts and toolbar icons to scripts

          • Process Notepad++ and Scintilla events, direct from a Python script

          • Python console built-in

          • Full regular expression support for search and replace - script Python regular expression replaces

          • Start external programs and pipe the output direct to a Notepad++ document, or filter it, or simply to the console window

          • Full documentation for all the objects and methods




          Source Python Script for Notepad++






          share|improve this answer































            0














            As DavidPostill wrote, this is not possible via Notepad++.



            However, if the list of replacements and the list of files in which to replace is short, I'd use the following manual approach:




            • first, replace XXX, because XXX is not part of X or XX (reversed, X is a part of XXX, and if you replace X first, e. g. with foo, then you will end up with foo, foofoo, foofoofoo.)

            • then replace XX


            • at the end, replace X



              test1=X
              test2=XX
              test3=XXX




            ctrl-a, ctrl-h



            search: XXX
            replace: foo



            test1=X
            test2=XX
            test3=foo


            ctrl-h



            search: XX
            replace: bar



            test1=X
            test2=bar
            test3=foo


            and so on.



            Counter example:



            test1=X
            test2=XX
            test3=XXX


            ctrl-a, ctrl-h



            search: X
            replace: foo



            test1=foo
            test2=foofoo
            test3=foofoofoo


            Alternatives



            Cygwin



            the first alternative which comes to my mind is Cygwin because it's installed on my PC anyway.



            Fire up Cygwin and use perl, sed or awk for replacement.



            Powershell



            As stated here, you could use some PowerShell script along the lines of



            (Get-Content test.txt) | ForEach-Object { $_ -replace "foo", "bar" } | Set-Content test2.txt


            Batch



            As stated here, you can also use Batch scripts, e. g.



            @echo off &setlocal
            setlocal enabledelayedexpansion

            set "search=%1"
            set "replace=%2"
            set "textfile=Input.txt"
            set "newfile=Output.txt"
            (for /f "delims=" %%i in (%textfile%) do (
            set "line=%%i"
            set "line=!line:%search%=%replace%!"
            echo(!line!
            ))>"%newfile%"
            del %textfile%
            rename %newfile% %textfile%
            endlocal





            share|improve this answer


























              Your Answer








              StackExchange.ready(function() {
              var channelOptions = {
              tags: "".split(" "),
              id: "3"
              };
              initTagRenderer("".split(" "), "".split(" "), channelOptions);

              StackExchange.using("externalEditor", function() {
              // Have to fire editor after snippets, if snippets enabled
              if (StackExchange.settings.snippets.snippetsEnabled) {
              StackExchange.using("snippets", function() {
              createEditor();
              });
              }
              else {
              createEditor();
              }
              });

              function createEditor() {
              StackExchange.prepareEditor({
              heartbeatType: 'answer',
              autoActivateHeartbeat: false,
              convertImagesToLinks: true,
              noModals: true,
              showLowRepImageUploadWarning: true,
              reputationToPostImages: 10,
              bindNavPrevention: true,
              postfix: "",
              imageUploader: {
              brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
              contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
              allowUrls: true
              },
              onDemand: true,
              discardSelector: ".discard-answer"
              ,immediatelyShowMarkdownHelp:true
              });


              }
              });














              draft saved

              draft discarded


















              StackExchange.ready(
              function () {
              StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fsuperuser.com%2fquestions%2f1106872%2fnotepad-replace-x-with-a-value-from-a-list%23new-answer', 'question_page');
              }
              );

              Post as a guest















              Required, but never shown

























              2 Answers
              2






              active

              oldest

              votes








              2 Answers
              2






              active

              oldest

              votes









              active

              oldest

              votes






              active

              oldest

              votes









              0














              I want to randomly replace X with a value from a list



              This is not possible using built in Notepad++ functionality.



              You could write a script to do it.



              There is a python script plugin for Notepad++:




              Python Script for Notepad++




              • Full programmatic access to Notepad++ features and menus

              • Full programmatic access to all of Scintilla features

              • Call other plugin menu items

              • Assign menu items, shortcuts and toolbar icons to scripts

              • Process Notepad++ and Scintilla events, direct from a Python script

              • Python console built-in

              • Full regular expression support for search and replace - script Python regular expression replaces

              • Start external programs and pipe the output direct to a Notepad++ document, or filter it, or simply to the console window

              • Full documentation for all the objects and methods




              Source Python Script for Notepad++






              share|improve this answer




























                0














                I want to randomly replace X with a value from a list



                This is not possible using built in Notepad++ functionality.



                You could write a script to do it.



                There is a python script plugin for Notepad++:




                Python Script for Notepad++




                • Full programmatic access to Notepad++ features and menus

                • Full programmatic access to all of Scintilla features

                • Call other plugin menu items

                • Assign menu items, shortcuts and toolbar icons to scripts

                • Process Notepad++ and Scintilla events, direct from a Python script

                • Python console built-in

                • Full regular expression support for search and replace - script Python regular expression replaces

                • Start external programs and pipe the output direct to a Notepad++ document, or filter it, or simply to the console window

                • Full documentation for all the objects and methods




                Source Python Script for Notepad++






                share|improve this answer


























                  0












                  0








                  0







                  I want to randomly replace X with a value from a list



                  This is not possible using built in Notepad++ functionality.



                  You could write a script to do it.



                  There is a python script plugin for Notepad++:




                  Python Script for Notepad++




                  • Full programmatic access to Notepad++ features and menus

                  • Full programmatic access to all of Scintilla features

                  • Call other plugin menu items

                  • Assign menu items, shortcuts and toolbar icons to scripts

                  • Process Notepad++ and Scintilla events, direct from a Python script

                  • Python console built-in

                  • Full regular expression support for search and replace - script Python regular expression replaces

                  • Start external programs and pipe the output direct to a Notepad++ document, or filter it, or simply to the console window

                  • Full documentation for all the objects and methods




                  Source Python Script for Notepad++






                  share|improve this answer













                  I want to randomly replace X with a value from a list



                  This is not possible using built in Notepad++ functionality.



                  You could write a script to do it.



                  There is a python script plugin for Notepad++:




                  Python Script for Notepad++




                  • Full programmatic access to Notepad++ features and menus

                  • Full programmatic access to all of Scintilla features

                  • Call other plugin menu items

                  • Assign menu items, shortcuts and toolbar icons to scripts

                  • Process Notepad++ and Scintilla events, direct from a Python script

                  • Python console built-in

                  • Full regular expression support for search and replace - script Python regular expression replaces

                  • Start external programs and pipe the output direct to a Notepad++ document, or filter it, or simply to the console window

                  • Full documentation for all the objects and methods




                  Source Python Script for Notepad++







                  share|improve this answer












                  share|improve this answer



                  share|improve this answer










                  answered Jul 30 '16 at 17:22









                  DavidPostillDavidPostill

                  108k27235270




                  108k27235270

























                      0














                      As DavidPostill wrote, this is not possible via Notepad++.



                      However, if the list of replacements and the list of files in which to replace is short, I'd use the following manual approach:




                      • first, replace XXX, because XXX is not part of X or XX (reversed, X is a part of XXX, and if you replace X first, e. g. with foo, then you will end up with foo, foofoo, foofoofoo.)

                      • then replace XX


                      • at the end, replace X



                        test1=X
                        test2=XX
                        test3=XXX




                      ctrl-a, ctrl-h



                      search: XXX
                      replace: foo



                      test1=X
                      test2=XX
                      test3=foo


                      ctrl-h



                      search: XX
                      replace: bar



                      test1=X
                      test2=bar
                      test3=foo


                      and so on.



                      Counter example:



                      test1=X
                      test2=XX
                      test3=XXX


                      ctrl-a, ctrl-h



                      search: X
                      replace: foo



                      test1=foo
                      test2=foofoo
                      test3=foofoofoo


                      Alternatives



                      Cygwin



                      the first alternative which comes to my mind is Cygwin because it's installed on my PC anyway.



                      Fire up Cygwin and use perl, sed or awk for replacement.



                      Powershell



                      As stated here, you could use some PowerShell script along the lines of



                      (Get-Content test.txt) | ForEach-Object { $_ -replace "foo", "bar" } | Set-Content test2.txt


                      Batch



                      As stated here, you can also use Batch scripts, e. g.



                      @echo off &setlocal
                      setlocal enabledelayedexpansion

                      set "search=%1"
                      set "replace=%2"
                      set "textfile=Input.txt"
                      set "newfile=Output.txt"
                      (for /f "delims=" %%i in (%textfile%) do (
                      set "line=%%i"
                      set "line=!line:%search%=%replace%!"
                      echo(!line!
                      ))>"%newfile%"
                      del %textfile%
                      rename %newfile% %textfile%
                      endlocal





                      share|improve this answer






























                        0














                        As DavidPostill wrote, this is not possible via Notepad++.



                        However, if the list of replacements and the list of files in which to replace is short, I'd use the following manual approach:




                        • first, replace XXX, because XXX is not part of X or XX (reversed, X is a part of XXX, and if you replace X first, e. g. with foo, then you will end up with foo, foofoo, foofoofoo.)

                        • then replace XX


                        • at the end, replace X



                          test1=X
                          test2=XX
                          test3=XXX




                        ctrl-a, ctrl-h



                        search: XXX
                        replace: foo



                        test1=X
                        test2=XX
                        test3=foo


                        ctrl-h



                        search: XX
                        replace: bar



                        test1=X
                        test2=bar
                        test3=foo


                        and so on.



                        Counter example:



                        test1=X
                        test2=XX
                        test3=XXX


                        ctrl-a, ctrl-h



                        search: X
                        replace: foo



                        test1=foo
                        test2=foofoo
                        test3=foofoofoo


                        Alternatives



                        Cygwin



                        the first alternative which comes to my mind is Cygwin because it's installed on my PC anyway.



                        Fire up Cygwin and use perl, sed or awk for replacement.



                        Powershell



                        As stated here, you could use some PowerShell script along the lines of



                        (Get-Content test.txt) | ForEach-Object { $_ -replace "foo", "bar" } | Set-Content test2.txt


                        Batch



                        As stated here, you can also use Batch scripts, e. g.



                        @echo off &setlocal
                        setlocal enabledelayedexpansion

                        set "search=%1"
                        set "replace=%2"
                        set "textfile=Input.txt"
                        set "newfile=Output.txt"
                        (for /f "delims=" %%i in (%textfile%) do (
                        set "line=%%i"
                        set "line=!line:%search%=%replace%!"
                        echo(!line!
                        ))>"%newfile%"
                        del %textfile%
                        rename %newfile% %textfile%
                        endlocal





                        share|improve this answer




























                          0












                          0








                          0







                          As DavidPostill wrote, this is not possible via Notepad++.



                          However, if the list of replacements and the list of files in which to replace is short, I'd use the following manual approach:




                          • first, replace XXX, because XXX is not part of X or XX (reversed, X is a part of XXX, and if you replace X first, e. g. with foo, then you will end up with foo, foofoo, foofoofoo.)

                          • then replace XX


                          • at the end, replace X



                            test1=X
                            test2=XX
                            test3=XXX




                          ctrl-a, ctrl-h



                          search: XXX
                          replace: foo



                          test1=X
                          test2=XX
                          test3=foo


                          ctrl-h



                          search: XX
                          replace: bar



                          test1=X
                          test2=bar
                          test3=foo


                          and so on.



                          Counter example:



                          test1=X
                          test2=XX
                          test3=XXX


                          ctrl-a, ctrl-h



                          search: X
                          replace: foo



                          test1=foo
                          test2=foofoo
                          test3=foofoofoo


                          Alternatives



                          Cygwin



                          the first alternative which comes to my mind is Cygwin because it's installed on my PC anyway.



                          Fire up Cygwin and use perl, sed or awk for replacement.



                          Powershell



                          As stated here, you could use some PowerShell script along the lines of



                          (Get-Content test.txt) | ForEach-Object { $_ -replace "foo", "bar" } | Set-Content test2.txt


                          Batch



                          As stated here, you can also use Batch scripts, e. g.



                          @echo off &setlocal
                          setlocal enabledelayedexpansion

                          set "search=%1"
                          set "replace=%2"
                          set "textfile=Input.txt"
                          set "newfile=Output.txt"
                          (for /f "delims=" %%i in (%textfile%) do (
                          set "line=%%i"
                          set "line=!line:%search%=%replace%!"
                          echo(!line!
                          ))>"%newfile%"
                          del %textfile%
                          rename %newfile% %textfile%
                          endlocal





                          share|improve this answer















                          As DavidPostill wrote, this is not possible via Notepad++.



                          However, if the list of replacements and the list of files in which to replace is short, I'd use the following manual approach:




                          • first, replace XXX, because XXX is not part of X or XX (reversed, X is a part of XXX, and if you replace X first, e. g. with foo, then you will end up with foo, foofoo, foofoofoo.)

                          • then replace XX


                          • at the end, replace X



                            test1=X
                            test2=XX
                            test3=XXX




                          ctrl-a, ctrl-h



                          search: XXX
                          replace: foo



                          test1=X
                          test2=XX
                          test3=foo


                          ctrl-h



                          search: XX
                          replace: bar



                          test1=X
                          test2=bar
                          test3=foo


                          and so on.



                          Counter example:



                          test1=X
                          test2=XX
                          test3=XXX


                          ctrl-a, ctrl-h



                          search: X
                          replace: foo



                          test1=foo
                          test2=foofoo
                          test3=foofoofoo


                          Alternatives



                          Cygwin



                          the first alternative which comes to my mind is Cygwin because it's installed on my PC anyway.



                          Fire up Cygwin and use perl, sed or awk for replacement.



                          Powershell



                          As stated here, you could use some PowerShell script along the lines of



                          (Get-Content test.txt) | ForEach-Object { $_ -replace "foo", "bar" } | Set-Content test2.txt


                          Batch



                          As stated here, you can also use Batch scripts, e. g.



                          @echo off &setlocal
                          setlocal enabledelayedexpansion

                          set "search=%1"
                          set "replace=%2"
                          set "textfile=Input.txt"
                          set "newfile=Output.txt"
                          (for /f "delims=" %%i in (%textfile%) do (
                          set "line=%%i"
                          set "line=!line:%search%=%replace%!"
                          echo(!line!
                          ))>"%newfile%"
                          del %textfile%
                          rename %newfile% %textfile%
                          endlocal






                          share|improve this answer














                          share|improve this answer



                          share|improve this answer








                          edited May 23 '17 at 12:41









                          Community

                          1




                          1










                          answered Jul 31 '16 at 6:49









                          stuejastueja

                          5011311




                          5011311






























                              draft saved

                              draft discarded




















































                              Thanks for contributing an answer to Super User!


                              • Please be sure to answer the question. Provide details and share your research!

                              But avoid



                              • Asking for help, clarification, or responding to other answers.

                              • Making statements based on opinion; back them up with references or personal experience.


                              To learn more, see our tips on writing great answers.




                              draft saved


                              draft discarded














                              StackExchange.ready(
                              function () {
                              StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fsuperuser.com%2fquestions%2f1106872%2fnotepad-replace-x-with-a-value-from-a-list%23new-answer', 'question_page');
                              }
                              );

                              Post as a guest















                              Required, but never shown





















































                              Required, but never shown














                              Required, but never shown












                              Required, but never shown







                              Required, but never shown

































                              Required, but never shown














                              Required, but never shown












                              Required, but never shown







                              Required, but never shown







                              Popular posts from this blog

                              Why not use the yoke to control yaw, as well as pitch and roll? Announcing the arrival of...

                              Couldn't open a raw socket. Error: Permission denied (13) (nmap)Is it possible to run networking commands...

                              VNC viewer RFB protocol error: bad desktop size 0x0I Cannot Type the Key 'd' (lowercase) in VNC Viewer...