Community
    • Login

    Replace every URL with the URL + text

    Scheduled Pinned Locked Moved Help wanted · · · – – – · · ·
    8 Posts 3 Posters 952 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.
    • شعر Techش
      شعر Tech
      last edited by

      I’m using Notepad++ and I can’t figure this out :

      I have a database of host and ports that looks like this :

      http://192.168.1.1:123
      http://18.81.1.25:12
      

      And I have another database that I need to replace this text with

      http://host:port/123
      http://host:port/124
      http://host:port/125
      http://host:port/126
      

      So that the result would be like this :

      http://192.168.1.1:123/123
      http://192.168.1.1:123/124
      http://192.168.1.1:123/125
      http://192.168.1.1:123/126
      
      http://18.81.1.25:12/123
      http://18.81.1.25:12/124
      http://18.81.1.25:12/125
      http://18.81.1.25:12/126
      

      So on and so forth

      Thanks :)

      PeterJonesP 1 Reply Last reply Reply Quote 0
      • PeterJonesP
        PeterJones @شعر Tech
        last edited by

        @شعر-Tech said in Replace every URL with the URL + text:

        I can’t figure this out :

        What did you try? Generally, it’s considered polite to include what you’ve already tried when asking such a question. That way, people can point you to the error of your ways (and get an idea of your current skill-level, so that the answer might be more understandable.)

        However, looking at your requirements: in general, wanting to do something with every line of group A combined with every line of group B is a Cartesian Product, and you will need general programming techniques. You might want to follow my advice for a similar (but not necessarily identical) Cartesian Product from last summer – start with that; if it’s not exactly what you want, try reading the PythonScript help files to modify it to accomplish what you do want; if you get stuck and have a specific problem, show us what you’ve tried, what it gives you, and what you were hoping for.

        1 Reply Last reply Reply Quote 3
        • شعر Techش
          شعر Tech
          last edited by

          I’m sorry I have only tried manually replacing the URL and I have no programming knowledge.
          Thanks a lot for yourhelp, I thought a plugin was already available that does that sort of thing but in retrospect you’re right I absolutely need programming.

          jcg3675J 1 Reply Last reply Reply Quote 0
          • jcg3675J
            jcg3675 @شعر Tech
            last edited by

            @شعر-Tech I might be able to make a simple C# program that does this. In the second chunk that starts with http://host:port/123, does the integer 123 always come after a slash?

            Or is there a case like this: http://host:port/123/456 where there is slash embedded in the number, you would want to copy 123/456 or just 456?

            شعر Techش 1 Reply Last reply Reply Quote 0
            • شعر Techش
              شعر Tech @jcg3675
              last edited by

              @jcg3675 Yes the integer always comes after the slash and no there’s no case like this : http://host:port/123/456

              Thanks a lot for your help :)

              1 Reply Last reply Reply Quote 0
              • jcg3675J
                jcg3675
                last edited by

                So I made a simple app, I call it HostPort, you can download it from the Microsoft Store here.

                Your PC needs to be running Windows 10, version 1903 or later. If you are using an earlier release of Windows 10, I can recompile it and update it pretty easily. Just tell me what version (you can find it in Settings > System > About). If you are using an older edition of Windows, like Windows 8 or Windows 7, it might take a little bit of time for me to port it–I do not usually work with 7 or 8. But I can try!

                If the program does not work as intended, let me know and I will make modifications as needed and update it.

                شعر Techش 1 Reply Last reply Reply Quote 3
                • شعر Techش
                  شعر Tech @jcg3675
                  last edited by

                  @jcg3675 It works perfectly just as intended !
                  I don’t know how I can thank you so if you need anything just ask :)

                  1 Reply Last reply Reply Quote 0
                  • jcg3675J
                    jcg3675
                    last edited by

                    Glad to hear that it works! You don’t owe me anything. Just pay it forward to someone else when the time comes :)

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