通过本文主要向大家介绍了asp调用js函数,asp instr函数,asp 字符串函数,asp split函数,asp replace函数等相关知识,希望对您有所帮助,也希望大家支持linkedu.com www.linkedu.com
********************
'函数作用:根据条件真假返回选定值中的某个
'参数:blnCondition:条件变量,varResultTrue:条件为真时返回值,varResultFalse:条件为假时返回值
Function IIF(blnCondition, varResultTrue,varResultFalse)
If CBool(blnCondition) Then
IIF = varResultTrue
Else
IIF = varResultFalse
End If
End Function
'********************
'函数作用:判断某个字符串元素是否在给定枚举中
'参数:sEle:待判断的字符串,sArray:指定枚举
'举例:根据扩展名判断是否图片文件:InArray(strFileExt,"jpg,gif,bmp,png")
Function InArray(sEle,sArray)
Dim aArray
Dim i
aArray = Split(sArray,",")
For i = 0 To UBound(aArray)
If Trim(sEle) = Trim(aArray(i)) Then
InArray = True
Exit Function
End If
Next
InArray = False
End Function
'********************
'函数作用:判断某个字符串是否符合正则表达式
'参数:strString:字符串,strPattern:正则表达式
Function doReTest(strString, strPattern)
Dim oRE
Set oRE = New RegExp
oRE.Pattern = strPattern
oRE.IgnoreCase = True
doReTest = oRE.Test(strString)
Set oRE = Nothing
End Function
'********************
'函数作用:正则提取
'参数:string:字符串,patrn:正则表达式
'返回:逗号分割的结果数组集成
Function doReExec(strng,patrn)
Dim regEx, Match, Matches,RetStr ' 创建变量。
Set regEx = New RegExp ' 创建正则表达式。
regEx.Pattern = patrn ' 设置模式。
regEx.IgnoreCase = True ' 设置为不区分大小写。
regEx.Global = True ' 设置全局适用。
Set Matches = regEx.Execute(strng) ' 执行搜索。
For Each Match in Matches ' 对 Matches 集合进行迭代。
RetStr = RetStr & Match.Value & "," & vbCRLF
Next
doReExec = RetStr
End Function
复制代码 '********************
'函数作用:显示分页链接
'参数:lngCurPage:当前页是第几页,lngPageCount:一共几页,strSueryString:分页链接需要附加的QueryString变量
Sub showPageNav(lngCurPage,lngPageCount,ByVal strQueryString)
Response.Write "当前第" & lngCurPage & "页,共:" & lngPageCount & "页"
Dim i,j,k
If lngCurPage = 1 Then '如果是第一页
'如果lngPageCount小于10,则导航页最多到lngPageCount页
If lngPageCount < 10 Then
j = lngPageCount
Else
j = 10
End If
For i = 2 To j
Response.Write("<a href=""?" & strQueryString & "&p=" & i & """>" & i & "</a> ")
Next
ElseIf lngCurPage = lngPageCount Then '如果是最后一页
'如果lngPageCount小于10,则导航起始从1开始
If lngPageCount < 10 Then
j = 1
Else
j = lngPageCount - 10
End If
For i = j To lngPageCount - 1
Response.Write("<a href=""?" & strQueryString & "&p=" & i & """>" & i & "</a> ")
Next
Response.Write(lPageCount)
Else '如果是中间的页
If lngCurPage <= 5 Then
j = 1
Else
j = lngCurPage - 5
End If
If lngPageCount <= lngCurPage + 5 Then
k = lngPageCount
Else
k = lngCurPage + 5
End If
Response.Write("<a href=""?" & strQueryString & "&p=" & 1 & """>" & "<<" & "</a> ")
For i = j To lngCurPage - 1
Response.Write("<a href=""?" & strQueryString & "&p=" & i & """>" & i & "</a> ")
Next
Response.Write(lngCurPage & " ")
For i = lngCurPage + 1 To k
&nb
'函数作用:根据条件真假返回选定值中的某个
'参数:blnCondition:条件变量,varResultTrue:条件为真时返回值,varResultFalse:条件为假时返回值
Function IIF(blnCondition, varResultTrue,varResultFalse)
If CBool(blnCondition) Then
IIF = varResultTrue
Else
IIF = varResultFalse
End If
End Function
'********************
'函数作用:判断某个字符串元素是否在给定枚举中
'参数:sEle:待判断的字符串,sArray:指定枚举
'举例:根据扩展名判断是否图片文件:InArray(strFileExt,"jpg,gif,bmp,png")
Function InArray(sEle,sArray)
Dim aArray
Dim i
aArray = Split(sArray,",")
For i = 0 To UBound(aArray)
If Trim(sEle) = Trim(aArray(i)) Then
InArray = True
Exit Function
End If
Next
InArray = False
End Function
'********************
'函数作用:判断某个字符串是否符合正则表达式
'参数:strString:字符串,strPattern:正则表达式
Function doReTest(strString, strPattern)
Dim oRE
Set oRE = New RegExp
oRE.Pattern = strPattern
oRE.IgnoreCase = True
doReTest = oRE.Test(strString)
Set oRE = Nothing
End Function
'********************
'函数作用:正则提取
'参数:string:字符串,patrn:正则表达式
'返回:逗号分割的结果数组集成
Function doReExec(strng,patrn)
Dim regEx, Match, Matches,RetStr ' 创建变量。
Set regEx = New RegExp ' 创建正则表达式。
regEx.Pattern = patrn ' 设置模式。
regEx.IgnoreCase = True ' 设置为不区分大小写。
regEx.Global = True ' 设置全局适用。
Set Matches = regEx.Execute(strng) ' 执行搜索。
For Each Match in Matches ' 对 Matches 集合进行迭代。
RetStr = RetStr & Match.Value & "," & vbCRLF
Next
doReExec = RetStr
End Function
复制代码 '********************
'函数作用:显示分页链接
'参数:lngCurPage:当前页是第几页,lngPageCount:一共几页,strSueryString:分页链接需要附加的QueryString变量
Sub showPageNav(lngCurPage,lngPageCount,ByVal strQueryString)
Response.Write "当前第" & lngCurPage & "页,共:" & lngPageCount & "页"
Dim i,j,k
If lngCurPage = 1 Then '如果是第一页
'如果lngPageCount小于10,则导航页最多到lngPageCount页
If lngPageCount < 10 Then
j = lngPageCount
Else
j = 10
End If
For i = 2 To j
Response.Write("<a href=""?" & strQueryString & "&p=" & i & """>" & i & "</a> ")
Next
ElseIf lngCurPage = lngPageCount Then '如果是最后一页
'如果lngPageCount小于10,则导航起始从1开始
If lngPageCount < 10 Then
j = 1
Else
j = lngPageCount - 10
End If
For i = j To lngPageCount - 1
Response.Write("<a href=""?" & strQueryString & "&p=" & i & """>" & i & "</a> ")
Next
Response.Write(lPageCount)
Else '如果是中间的页
If lngCurPage <= 5 Then
j = 1
Else
j = lngCurPage - 5
End If
If lngPageCount <= lngCurPage + 5 Then
k = lngPageCount
Else
k = lngCurPage + 5
End If
Response.Write("<a href=""?" & strQueryString & "&p=" & 1 & """>" & "<<" & "</a> ")
For i = j To lngCurPage - 1
Response.Write("<a href=""?" & strQueryString & "&p=" & i & """>" & i & "</a> ")
Next
Response.Write(lngCurPage & " ")
For i = lngCurPage + 1 To k
&nb