• Login
Community
  • Login

Keeping the 2 first digits from an IP?

Scheduled Pinned Locked Moved Help wanted · · · – – – · · ·
8 Posts 3 Posters 423 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.
  • R
    Roger St-Onge
    last edited by Apr 9, 2022, 12:47 PM

    I have this range of IP’s:
    19.20.21.22
    19.21.22.23
    20.150.172.28
    20.192.238.24
    21.193.128.44
    22.193.12.6

    I want to keep only the 2 first digits and delete duplicates

    Results:
    19
    20
    21

    A 1 Reply Last reply Apr 9, 2022, 12:59 PM Reply Quote 0
    • A
      Alan Kilborn @Roger St-Onge
      last edited by Apr 9, 2022, 12:59 PM

      @roger-st-onge

      Find: (?-s)^(\d+)\..+
      Replace: ${1}
      Search mode: Regular expression

      Follow that with this action:

      76a16a3d-6f38-4677-b8c6-3ecab453a1f5-image.png

      L R 2 Replies Last reply Apr 9, 2022, 7:23 PM Reply Quote 4
      • L
        Lycan Thrope @Alan Kilborn
        last edited by Apr 9, 2022, 7:23 PM

        @alan-kilborn ,
        Thanks Alan, another NPP capability I wasn’t aware of…but that just means my needs haven’t been expansive enough to seek it out, but I’m getting there. :)

        1 Reply Last reply Reply Quote 2
        • R
          Roger St-Onge @Alan Kilborn
          last edited by Apr 11, 2022, 11:01 AM

          @alan-kilborn, look like it’s not finding anything…376221ff-ce11-4d35-af78-761a01f71c9c-image.png

          R 1 Reply Last reply Apr 11, 2022, 11:44 AM Reply Quote 0
          • R
            Roger St-Onge @Roger St-Onge
            last edited by Apr 11, 2022, 11:44 AM

            @roger-st-onge Still having issue, not able to make it work5c4a0f86-258f-4e2a-a3b0-1b797eb3dd47-image.png

            A 1 Reply Last reply Apr 11, 2022, 11:55 AM Reply Quote 0
            • A
              Alan Kilborn @Roger St-Onge
              last edited by Apr 11, 2022, 11:55 AM

              @roger-st-onge

              It’s because you misrepresented your data.
              What you showed originally started in column 1 (well, as far as anyone could tell).
              The ^ in the expression means start-of-line must occur there.
              Experiment with removing that character from the find expression.
              Also a good idea to read up on regular expression searching; see this site’s FAQ page.

              R 1 Reply Last reply Apr 19, 2022, 12:26 PM Reply Quote 3
              • R
                Roger St-Onge @Alan Kilborn
                last edited by Apr 19, 2022, 12:26 PM

                @alan-kilborn

                Thanks for helping a Newbie :) With your help I was able to achive my task.

                Solution to clean up AWS Public IP list
                https://ip-ranges.amazonaws.com/ip-ranges.json

                Removed all alphabet: \b(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(.(?1)){3}\b

                412be648-63bb-4714-8a80-80083ea65131-image.png

                Then

                Find: (?-s)^(\d+)…+
                Replace: ${1}
                Search mode: Regular expression

                Then

                839e2b87-2c73-4d67-af76-084cab350c77-image.png

                Final Results for first set of IP’s in Microsoft Azure Publip IP List
                d9f2f80c-8b65-4fd4-8e16-be9cb59863dc-image.png

                1 Reply Last reply Reply Quote 0
                • R
                  Roger St-Onge
                  last edited by Apr 19, 2022, 12:28 PM

                  Note this is for Azure Public IP List,
                  not for AWS

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