Community
    • Login

    Keeping the 2 first digits from an IP?

    Scheduled Pinned Locked Moved Help wanted · · · – – – · · ·
    8 Posts 3 Posters 394 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.
    • Roger St-OngeR
      Roger St-Onge
      last edited by

      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

      Alan KilbornA 1 Reply Last reply Reply Quote 0
      • Alan KilbornA
        Alan Kilborn @Roger St-Onge
        last edited by

        @roger-st-onge

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

        Follow that with this action:

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

        Lycan ThropeL Roger St-OngeR 2 Replies Last reply Reply Quote 4
        • Lycan ThropeL
          Lycan Thrope @Alan Kilborn
          last edited by

          @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
          • Roger St-OngeR
            Roger St-Onge @Alan Kilborn
            last edited by

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

            Roger St-OngeR 1 Reply Last reply Reply Quote 0
            • Roger St-OngeR
              Roger St-Onge @Roger St-Onge
              last edited by

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

              Alan KilbornA 1 Reply Last reply Reply Quote 0
              • Alan KilbornA
                Alan Kilborn @Roger St-Onge
                last edited by

                @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.

                Roger St-OngeR 1 Reply Last reply Reply Quote 3
                • Roger St-OngeR
                  Roger St-Onge @Alan Kilborn
                  last edited by

                  @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
                  • Roger St-OngeR
                    Roger St-Onge
                    last edited by

                    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