arfer Master

Joined: 26 Nov 2004 Posts: 436 Location: Manchester, UK
|
Posted: Wed May 05, 2010 6:06 am Post subject: |
|
|
[11:00] <@arfer> % return [regexp -- {(\d{1,3}\.){3}\d{1,3}} 123.235.26.5]
[11:00] <@Baal> 1
[11:00] <@arfer> % return [regexp -- {(\d{1,3}\.){3}\d{1,3}} 123.235.2a.5]
[11:00] <@Baal> 0
Don't forget that this is not sufficient by itself to determine if a string is a valid ipv4 numeric ip. You will have to split the string at '.' and test if each octet is <= 255.
I suppose life gets even more difficult if you also want to determine if it is a valid external IP, for example not loopback or private lan. I have some code somewhere for these tests. If you have any interest, I will try to dig it out. _________________ I must have had nothing to do |
|