«

ASP中如何使用Instr判断多个IP地址是否存在?

时间:2024-12-24 07:32     作者:emer     分类:


asp中用instr判断多个ip地址

在asp中,可以通过使用instr函数来判断字符串中是否包含指定子字符串。但是,如果需要判断字符串中是否包含多个子字符串,则需要采用其他方法。

一种方法是使用循环遍历,对每个子字符串执行instr判断:

<%
Dim aa, ipList, ip, found
aa = Request.ServerVariables("REMOTE_ADDR")

ipList = Array("99.88", "110.52", "43.80.235", "11.9.67.180")
found = False

For Each ip In ipList
    If InStr(aa, ip) > 0 Then
        found = True
        Exit For
    End If
Next

If found Then
    Response.Write "ok"
    Response.End
End If
%>
登录后复制

这种方法更具灵活性,可以轻松添加或删除需要判断的子字符串。

以上就是ASP中如何使用Instr判断多个IP地址是否存在?的详细内容,更多请关注php中文网其它相关文章!