又一次发几个ASP不错的函数
******************** '函数作用:根据条件真假返回选定值中的某个 '参数: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) ' 执行搜索。 (编辑:银川站长网) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |