原创]VBS中的正则表达式的用法大全" target="_blank">[原创]VBS中的正则表达式的用法大全


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

[Ctrl+A 全选 注:如需引入外部Js需刷新才能执行]

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.phpstudy.net/html/200608/6/574.htm
« 
» 
快速导航

Copyright © 2016 phpStudy | 豫ICP备2021030365号-3