Re: checking a IP sent from form
Re: checking a IP sent from form
am 22.12.2007 14:59:07 von Anthony Jones
"Bam" wrote in message
news:476699c1$0$29656$4c368faf@roadrunner.com...
> Here is what I am needing, and can't figure it out.
>
> I have a form field that will contain an IP based on a TeamSpeak or
Ventrilo
> IP.
> What I need to do, is check to make sure there are 4 groups of numbers in
> the form field. Or, check to see if the entry contains 3 periods. 1.2.3.4
> <--- example there are 4 groups, and 3 periods.
> Now of course, the IP can be as large as 4 groups of 3 numbers, so I can't
> check string length.
>
Testing a valid IP address format is a little more involved. For example,
24.75.345.200 looks valid enough (the director to the movie "The NET"
thought so) but it isn't.
Here is code I would use in this case (watch for line wrap):-
Const csPatternIP =
"^(((\d{1,2})|(1\d{2})|(2[0-4]\d)|(25[0-5]))\.){3}((\d{1,2}) |(1\d{2})|(2[0-4
]\d)|(25[0-5]))$"
If (NewRexExp(csPatternIP).Test(sIP) Then
'IP seems good
Else
'IP is clearly invalid
End If
Function NewRegExp(rsPattern)
Set NewRegExp = new RegExp
NewRegExp.IgnoreCase = rbCaseInsensitive
End Function
--
Anthony Jones - MVP ASP/ASP.NET
Re: checking a IP sent from form
am 27.12.2007 00:48:46 von Bam
--
Thanks,
Bam
"Anthony Jones" wrote in message
news:uzL1SLKRIHA.5988@TK2MSFTNGP02.phx.gbl...
>
> "Bam" wrote in message
> news:476699c1$0$29656$4c368faf@roadrunner.com...
>> Here is what I am needing, and can't figure it out.
>>
>> I have a form field that will contain an IP based on a TeamSpeak or
> Ventrilo
>> IP.
>> What I need to do, is check to make sure there are 4 groups of numbers in
>> the form field. Or, check to see if the entry contains 3 periods.
>> 1.2.3.4
>> <--- example there are 4 groups, and 3 periods.
>> Now of course, the IP can be as large as 4 groups of 3 numbers, so I
>> can't
>> check string length.
>>
>
> Testing a valid IP address format is a little more involved. For example,
> 24.75.345.200 looks valid enough (the director to the movie "The NET"
> thought so) but it isn't.
>
> Here is code I would use in this case (watch for line wrap):-
>
> Const csPatternIP =
> "^(((\d{1,2})|(1\d{2})|(2[0-4]\d)|(25[0-5]))\.){3}((\d{1,2}) |(1\d{2})|(2[0-4
> ]\d)|(25[0-5]))$"
>
> If (NewRexExp(csPatternIP).Test(sIP) Then
> 'IP seems good
> Else
> 'IP is clearly invalid
> End If
>
> Function NewRegExp(rsPattern)
>
> Set NewRegExp = new RegExp
> NewRegExp.IgnoreCase = rbCaseInsensitive
>
> End Function
>
>
> --
> Anthony Jones - MVP ASP/ASP.NET
>
>
It wouldn't have to check to see if it is an actual working IP, just check
to see if it meets the ip criteria, which should be 4 groups of numbers that
can be one digit to four digits per group.
Bam
Re: checking a IP sent from form
am 27.12.2007 12:29:01 von Anthony Jones
"Bam" wrote in message
news:4772e75c$0$4315$4c368faf@roadrunner.com...
>
>
> --
> Thanks,
> Bam
> "Anthony Jones" wrote in message
> news:uzL1SLKRIHA.5988@TK2MSFTNGP02.phx.gbl...
> >
> > "Bam" wrote in message
> > news:476699c1$0$29656$4c368faf@roadrunner.com...
> >> Here is what I am needing, and can't figure it out.
> >>
> >> I have a form field that will contain an IP based on a TeamSpeak or
> > Ventrilo
> >> IP.
> >> What I need to do, is check to make sure there are 4 groups of numbers
in
> >> the form field. Or, check to see if the entry contains 3 periods.
> >> 1.2.3.4
> >> <--- example there are 4 groups, and 3 periods.
> >> Now of course, the IP can be as large as 4 groups of 3 numbers, so I
> >> can't
> >> check string length.
> >>
> >
> > Testing a valid IP address format is a little more involved. For
example,
> > 24.75.345.200 looks valid enough (the director to the movie "The NET"
> > thought so) but it isn't.
> >
> > Here is code I would use in this case (watch for line wrap):-
> >
> > Const csPatternIP =
> >
"^(((\d{1,2})|(1\d{2})|(2[0-4]\d)|(25[0-5]))\.){3}((\d{1,2}) |(1\d{2})|(2[0-4
> > ]\d)|(25[0-5]))$"
> >
> > If (NewRexExp(csPatternIP).Test(sIP) Then
> > 'IP seems good
> > Else
> > 'IP is clearly invalid
> > End If
> >
> > Function NewRegExp(rsPattern)
> >
> > Set NewRegExp = new RegExp
> > NewRegExp.IgnoreCase = rbCaseInsensitive
> >
> > End Function
> >
> >
> > --
> > Anthony Jones - MVP ASP/ASP.NET
> >
> >
>
> It wouldn't have to check to see if it is an actual working IP, just check
> to see if it meets the ip criteria, which should be 4 groups of numbers
that
> can be one digit to four digits per group.
>
You meant of course 3 digits per group. The RegEx pattern also tests that
the number in each group is between 0-255.
--
Anthony Jones - MVP ASP/ASP.NET
Re: checking a IP sent from form
am 31.12.2007 19:24:44 von Bam
thanks!!!
--
"Anthony Jones" wrote in message
news:O8QgvuHSIHA.4180@TK2MSFTNGP06.phx.gbl...
> "Bam" wrote in message
> news:4772e75c$0$4315$4c368faf@roadrunner.com...
>>
>>
>> --
>> Thanks,
>> Bam
>> "Anthony Jones" wrote in message
>> news:uzL1SLKRIHA.5988@TK2MSFTNGP02.phx.gbl...
>> >
>> > "Bam" wrote in message
>> > news:476699c1$0$29656$4c368faf@roadrunner.com...
>> >> Here is what I am needing, and can't figure it out.
>> >>
>> >> I have a form field that will contain an IP based on a TeamSpeak or
>> > Ventrilo
>> >> IP.
>> >> What I need to do, is check to make sure there are 4 groups of numbers
> in
>> >> the form field. Or, check to see if the entry contains 3 periods.
>> >> 1.2.3.4
>> >> <--- example there are 4 groups, and 3 periods.
>> >> Now of course, the IP can be as large as 4 groups of 3 numbers, so I
>> >> can't
>> >> check string length.
>> >>
>> >
>> > Testing a valid IP address format is a little more involved. For
> example,
>> > 24.75.345.200 looks valid enough (the director to the movie "The NET"
>> > thought so) but it isn't.
>> >
>> > Here is code I would use in this case (watch for line wrap):-
>> >
>> > Const csPatternIP =
>> >
> "^(((\d{1,2})|(1\d{2})|(2[0-4]\d)|(25[0-5]))\.){3}((\d{1,2}) |(1\d{2})|(2[0-4
>> > ]\d)|(25[0-5]))$"
>> >
>> > If (NewRexExp(csPatternIP).Test(sIP) Then
>> > 'IP seems good
>> > Else
>> > 'IP is clearly invalid
>> > End If
>> >
>> > Function NewRegExp(rsPattern)
>> >
>> > Set NewRegExp = new RegExp
>> > NewRegExp.IgnoreCase = rbCaseInsensitive
>> >
>> > End Function
>> >
>> >
>> > --
>> > Anthony Jones - MVP ASP/ASP.NET
>> >
>> >
>>
>> It wouldn't have to check to see if it is an actual working IP, just
>> check
>> to see if it meets the ip criteria, which should be 4 groups of numbers
> that
>> can be one digit to four digits per group.
>>
>
> You meant of course 3 digits per group. The RegEx pattern also tests that
> the number in each group is between 0-255.
>
>
> --
> Anthony Jones - MVP ASP/ASP.NET
>
>