' 5. 匹配格式(只允许大小写英文字母) reg.Pattern = "^[a-zA-Z]*$" If reg.test("accDDggh7") Then MsgBox "5. 数据合法!" Else MsgBox "5. 数据非法(只允许大小写英文字母及逗号)!" End If
' 6. 匹配格式(只允许大小写英文字母,阿拉伯数字及逗号) reg.Pattern = "^[a-zA-Z0-9,]*$" If reg.test("a,bc77,d,ef,") Then MsgBox "6. 数据合法!" Else MsgBox "6. 数据非法(只允许大小写英文字母,阿拉伯数字及逗号)!" End If End Sub
' 提取字符串 Sub test() Dim strOld As String, strNew As String Dim myRegExp As RegExp Set myRegExp = New RegExp
myRegExp.Global = True strOld = "<div class=""dashed"">编辑推荐</div>" myRegExp.Pattern = "(?:<div class=""dashed"">)(.+)(??:</div>))" strNew = myRegExp.Replace(strOld, "$1") MsgBox strNew End Sub