Re: IP range regex question



Randal L. Schwartz wrote:

"Tuxedo" == Tuxedo <tuxedo@xxxxxxxxxxxxxx> writes:

Tuxedo> Knowing the IP number of a website visitors, for example
Tuxedo> 87.163.115.64, what type of regular expression can be used to
Tuxedo> identify whether this calling IP number is in the list or not?

As you are quickly discovering, a regex is not the solution for this
problem. You already have numbers... why are you turning that into a
*string* and then doing *string processing* on it?

Thanks for the tip what not to do! That a solution may be regex based was
only my assumption.

If a solution can't be achieved particularly well by a regex, can you or
anyone elaborate a bit on a better solution to identify if a particular IP,
eg. 87.163.115.64, exists in an example text file, whether the file used
contains lines of an IP range formatted list or a so-called CIDR type range:
31.172.160.0 - 31.172.191.255
....
Or in CIDR format:
31.172.160.0/19
etc.

I'm not sure what the better format of the two list types to base an
identification are? The site where I found both lists -
http://www.find-ip-address.org/ip-country - suggest that "The CIDR system
offers more efficient routing if the routing protocols support it."
Perhaps this is something that also happens to be relevant to a simple IP
matching task or not? I have no idea.... The CIDR formatted list certainly
makes a much bigger text file.

Thanks,
Tuxedo

.



Relevant Pages