Skip to content
Advertisement

Tag: ip

Getting City from IP Address range

I have an IP address. For example, 192.168.2.10 Also I have a dictionary: Question: How should I find the city from my IP address and use this dictionary spending less time (time complexity) as possible? Answer The “proper answer” if you want the best complexity for arbitrarily large data sets is the one given given by Ji Bin. To really

How to match IP addresses in a comma-separated string

Code show as below, but there is a problem: “255.255.255.256” will be processed into “255.255.255.25” If I pass the 255.255.255.255,255.255.255.256,260.255.255.255 string I expect [“255.255.255.255”] as the results. Answer You want to implement comma boundaries, (?<![^,]) and (?![^,]): See the regex demo. Details (?<![^,]) – a negative lookbehind that matches a location not immediately preceded with a char other than a

Convert IP address string to binary in Python

As part of a larger application, I am trying to convert an IP address to binary. Purpose being to later calculate the broadcast address for Wake on LAN traffic. I am assuming that there is a much more efficient way to do this then the way I am thinking. Which is breaking up the IP address by octet, adding 0’s

Advertisement