QTP自動化測試之VBScript對象(5)

發表于:2012-01-18來源:博客園作者:  known點擊數: 標簽:QTP自動化測試
5. RegExp對象 RegExp是正則表達式對象,提供簡單的正則表達式支持功能。主要屬性有Global、IgnoreCase、Pattern,主要方法有Execute、Replace、Test,其屬性及方法的

  5. RegExp對象

  RegExp是正則表達式對象,提供簡單的正則表達式支持功能。主要屬性有Global、IgnoreCase、Pattern,主要方法有Execute、Replace、Test,其屬性及方法的詳細說明詳見參考文檔。下面的示例說明了RegExp對象的用法:

  ?

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
Function RegExpTest(patrn, strng)
    Dim regEx, match, matches            '建立變量。
    Set regEx = New RegExp               '建立正則表達式。
    regEx.Pattern = patrn                '設置模式。
    regEx.IgnoreCase = True              '設置是否區分字符大小寫。
    regEx.Global = True                  '設置全局可用性。
    Set matches = regEx.Execute(strng)   '執行搜索。
    For Each match in matches            '遍歷匹配集合。
        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"))

原文轉自:http://www.anti-gravitydesign.com

国产97人人超碰caoprom_尤物国产在线一区手机播放_精品国产一区二区三_色天使久久综合给合久久97