VBS正则表达式函数
主要用在asp中效果明显
1、表单验证功能
复制代码 代码如下:
Function Validate(strng,patrn)
Dim regEx
Set regEx = New RegExp
regEx.Pattern = patrn
regEx.IgnoreCase = True
regEx.Global = True
Validate = regEx.test(strng)
Set regEx = Nothing
End Function
使用例子
If Validate(Fdr.Name,"F/d{4}_P/d{4}")=True Then
... ...
End If
2、替换功能
复制代码 代码如下:
'==========================
'用正则表达式实现替换
'==========================
function replaceregex(patern,str,tagstr)
dim regex,matches
set regex=new regExp
regex.pattern=patern
regex.IgnoreCase=true
regex.global=true
matches=regex.replace(str,tagstr)
replaceregex=matches
end function
3、ubb功能
http://www.jb51.net/html/200608/6/574.htm