当前位置:编程学习 > asp >>

用划界字符列表来得到字符所在串的位置(ListFind函数)

答案:<%
' Company: Sabra Inc
' Author: Dave Hoffenberg
' Function: Finds a value within a delimited list
' Freeware

Function ListFind(value,list,delim)

If list <> "" Then

arr = split(list,delim)

For i=0 to ubound(arr)

If arr(i) = value Then
Match = 1
Exit For
Else
Match = 0
End If

Next

ListFind = Match

Else

ListFind = 0

End If

End Function

strList = "1,2,3"
response.write ListFind("1",strList,",")

response.write "<br>"

strList = "a-b-c"
response.write ListFind("a",strList,"-")
%>

上一个:vbscript和javascript互相调用
下一个:JScript 方法 - join 方法

CopyRight © 2022 站长资源库 编程知识问答 zzzyk.com All Rights Reserved
部分文章来自网络,