Identifying an IP address

Jim Ault JimAultWins at yahoo.com
Fri Apr 6 05:04:16 EDT 2007


Since you have not specified rules for the valid IP addresses  I am assuming
that each part needs to be a 1-3 digit number and limited to the numbering
ranges, eg 255 max.  RegEx will have to be constructed very intricately to
do this kind of filtering, so you will be better off building your own
filter.

Are you locating IP addresses in a block of text or lines?
Are you testing a single address?
Do you need to know what is wrong with address to notify a user?

Chunk expressions run very fast, so this might be the best option
---------------
get ipString
replace "." with 0 in it
if it is not a number then -- typo

get ipString & null
replace "." with cr in it
if the number of lines in it <> 4 then --wrong number of parts

repeat for each line LNN in it
         if LNN > 255 then --out of range
end repeat

if line 1 of it =192 and line 2 of it = 168 then --local network IP

Jim Ault
Las Vegas


On 4/6/07 2:06 AM, "jbv" <jbv.silences at club-internet.fr> wrote:

> 
> 
> Eric,
> 
>> Bonjour,
>> 
>> Regex!
>> http://regexlib.com/default.aspx
>> 
> 
> yes, I'm using Regex :
> 
>  put "(\d{1,3}\.){3}\d{1,3}" into myRegex
>  get matchtext(myIP , myRegex)
> 
> but this one detects only 4 patterns of 1 to 3 digits separated
> by dots, hence my original concern : it will also include non
> valide IPs such as 999.999.999.999, as well as private IPs...
> 
> I made quite a lot of google searches but didn't find any
> regex that's 100% efficient...
> I'm afraid I'll have to use a Transcript function instead, which
> will probably mean slower code...
> 
> JB
> 
> _______________________________________________
> use-revolution mailing list
> use-revolution at lists.runrev.com
> Please visit this url to subscribe, unsubscribe and manage your subscription
> preferences:
> http://lists.runrev.com/mailman/listinfo/use-revolution





More information about the use-livecode mailing list