Snitz™ Forums 2000
https://forum.snitz.com/forumTopic/Posts/68094?pagenum=1
05 November 2025, 08:47
Topic
bobby131313
Beginning of a string....
17 January 2009, 13:49
Code:
If InStr(Request.ServerVariables("REMOTE_ADDR"),"41.207") > 0 Then
Is there a way I can make sure this only matches at the beginning of the string?
For example...
Match > 41.207.256.325 Do not match > 256.41.207.325
Thanks!<
Replies ...
ruirib
17 January 2009, 17:25
If there is a match, the matching position will be returned, so you just need to check the value. If 1, it's the beginning of the string, if greater than 1 you know it wasn't matched at the beginning of the string.<
bobby131313
17 January 2009, 18:15
Ahhhhh... So I would want...
Code:
If InStr(Request.ServerVariables("REMOTE_ADDR"),"41.207") = 1 Then
Never knew that. Thanks! <
ruirib
17 January 2009, 18:27
Originally posted by bobby131313 Ahhhhh... So I would want...
Code:
If InStr(Request.ServerVariables("REMOTE_ADDR"),"41.207") = 1 Then
Never knew that. Thanks!
Yeppers... you're welcome .<
Carefree
17 January 2009, 20:12
If InStr(Request.ServerVariables("REMOTE_ADDR"),"41.207") = 1 Then
does the same thing as
if left(Request.ServerVariables("REMOTE_ADDR",6))="41.207" then<
bobby131313
17 January 2009, 20:20
Good to know....
So...
Code:
If InStr(Request.ServerVariables("REMOTE_ADDR"),"41.207") = 1 Then Go the hell away!
end if
and
Code:
if left(Request.ServerVariables("REMOTE_ADDR",6))="41.207" then Go the hell away!
end if
Will do the same thing.... Thanks!
<
Doug G
18 January 2009, 02:55
Using a fixed length extract will fail if your next problem visitor is from an IP like "241.207" Now it's 7 characters long. I'd use rui's solution.
<
Carefree
18 January 2009, 03:49
Originally posted by Doug G Using a fixed length extract will fail if your next problem visitor is from an IP like "241.207" Now it's 7 characters long. I'd use rui's solution.
However, since he specified he wanted "the beginning of the string", then he would not want a match of "241.207".<