【软件自动化测试 - VBScript 7】= Using Locate to determine if specific text exists within a string

'Locate Method
' Using Locate to determine if specific text exists within a string.

 
MsgBox LocateText("http://blog.csdn.net/xuyubotest", "xuyubotest")
MsgBox LocateText("http://blog.csdn.net/xuyubotest", "QTP.*.com")

' =============================================================
' function: LocateText
' desc :    Uses a regular expression to locate text within a string
' params :  strString is the string to perform the search on
'           strPattern is the regular expression
' returns : True if the pattern was found, False otherwise
' =============================================================
Function LocateText(strString, strPattern)

Dim objRegEx

' create the regular expression
Set objRegEx = New RegExp

' set the pattern
objRegEx.Pattern = strPattern

' ignore the casing
objRegEx.IgnoreCase = True

' perform the search
LocateText = objRegEx.Test(strString)

' destroy the object
Set objRegEx = Nothing

End Function
' LocateText

你可能感兴趣的:(String,function,测试,search,VBScript)