Keeping the 2 first digits from an IP?
-
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.6I want to keep only the 2 first digits and delete duplicates
Results:
19
20
21 -
Find:
(?-s)^(\d+)\..+
Replace:${1}
Search mode: Regular expressionFollow that with this action:
-
@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. :) -
@alan-kilborn, look like it’s not finding anything…
-
@roger-st-onge Still having issue, not able to make it work
-
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. -
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.jsonRemoved all alphabet: \b(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(.(?1)){3}\b
Then
Find: (?-s)^(\d+)…+
Replace: ${1}
Search mode: Regular expressionThen
Final Results for first set of IP’s in Microsoft Azure Publip IP List
-
Note this is for Azure Public IP List,
not for AWS