正则表达式判断函数
如果写一个正则判断 函数 要求返回值为一个布尔值:) Function RegExpTest(patrn, strng)Dim regEx, Match, Matches ' Create variable.
Set regEx = New RegExp ' Create a regular expression.
regEx.Pattern = patrn ' Set pattern.
regEx.IgnoreCase = True ' Set case insensitivity.
regEx.Global = True ' Set global applicability.
Set Matches = regEx.Execute(strng) ' Execute search.
For Each Match in Matches ' Iterate Matches collection.
RetStr = RetStr & "Match found at position "
RetStr = RetStr & Match.FirstIndex & ". Match Value is '"
RetStr = RetStr & Match.Value & "'." & vbCRLF
Next
RegExpTest = RetStr
End Function
MsgBox(RegExpTest("is.", "IS1 is2 IS3 is4")) Function RegExpTest(patrn, strng)
Dim regEx, retVal ' Create variable.
Set regEx = New RegExp ' Create regular expression.
regEx.Pattern = patrn ' Set pattern.
regEx.IgnoreCase = False ' Set case sensitivity.
retVal = regEx.Test(strng) ' Execute the search test.
RegExpTest=retVal
End Function
MsgBox(RegExpTest("is.", "IS1 is2 IS3 is4"))
[ 本帖最后由 wugecat 于 2010-1-28 16:00 编辑 ] 十分感谢:victory: 这个只是我们从F1上取来的,具体需求具体代码
页:
[1]