如何引用 RegExp Object
引用自MSDN
-------------------------------------------------------------------------
The RegExp Object is an intrinsic global object that stores information about the results of regular expression pattern matches.
-------------------------------------------------------------------------
问题点数:20、回复次数:4Top
1 楼bitmoon(bitmoon)回复于 2003-06-01 09:51:09 得分 5
我引用的是microsoft vbscript regular expression 5.5Top
2 楼foxzk(狐狸糊涂)回复于 2003-06-02 15:48:33 得分 0
bitmoon(bitmoon) 有没有引用那个DLL tlb 可以直接使用 RegExp Object 正则表达式 谢谢Top
3 楼bitmoon(bitmoon)回复于 2003-06-03 08:41:55 得分 0
不明白你说的什么意思Top
4 楼ch21st(www.blanksoft.com)回复于 2003-06-03 09:46:35 得分 15
如果你以前没有使用过RegExp对象,你需要下载VBScript 5.0 DLL,地址为:
http://www.microsoft.com/msdownload/vbscript/scripting.asp
一旦你安装了VBScript的 DLL, Microsoft VBScript Regular Expressions选项就出现在Visual Basic的参考(References)对话框中
下面的代码将校验文本框Text1中的电子邮件地址。
Dim myReg As RegExp
Private Sub Form_Load()
Set myReg = New RegExp
myReg.IgnoreCase = True
myReg.Pattern = "^[\w-\.]+@\w+\.\w+$"
End Sub
Private Sub Text1_Validate(Cancel As Boolean)
Cancel = Not myReg.Test(Text1)
End Sub
这里,Pattern属性接受任意数目的出现在@前后的数字、下划线、字母、“-”或“.” 。
Top




