• <ruby id="5koa6"></ruby>
    <ruby id="5koa6"><option id="5koa6"><thead id="5koa6"></thead></option></ruby>

    <progress id="5koa6"></progress>

  • <strong id="5koa6"></strong>
    • 軟件測試技術
    • 軟件測試博客
    • 軟件測試視頻
    • 開源軟件測試技術
    • 軟件測試論壇
    • 軟件測試沙龍
    • 軟件測試資料下載
    • 軟件測試雜志
    • 軟件測試人才招聘
      暫時沒有公告

    字號: | 推薦給好友 上一篇 | 下一篇

    vb中使用正則表達式

    發布: 2007-7-14 20:28 | 作者: 佚名    | 來源: 網絡轉載     | 查看: 29次 | 進入軟件測試論壇討論

    領測軟件測試網 步示例
    1. 啟動 Microsoft Visual Basic 6.0。
    2. 在“文件”菜單上,單擊“新建項目”。
    3. 在“新建項目”對話框中,單擊“Standard Exe”,然后單擊“確定”。

    默認情況下將創建 Form1。
    4. 在“項目”菜單上單擊“引用”。
    5. 雙擊“Microsoft VBScript Regular Expressions 5.5”,然后單擊“確定”。
    6. 在工具箱中,雙擊“命令按鈕”。

    默認情況下,“Command1”將添加到窗體中。
    7. 雙擊“Command1”以打開代碼窗口。
    8. 將下面的代碼粘貼到“Command1_Click”事件處理程序:MsgBox(TestRegExp("is.", "IS1 is2 IS3 is4"))
    注意 這個示例中將對照“IS1 is2 IS3 is4”字符串檢查 is. 模式。您可以將句點這一特殊字符(.)用作通配符,這樣,搜索模式就能夠多匹配并多顯示一個字符。如果您在搜索模式中添加兩個句點,您會看到兩個其他字符。如果您不使用任何句點,您只會看到搜索模式。
    9. 將以下函數添加到“Command1_click”事件處理程序后:Function TestRegExp(myPattern As String, myString As String)
       ''Create objects.
       Dim objRegExp As RegExp
       Dim objMatch As Match
       Dim colMatches   As MatchCollection
       Dim RetStr As String

       '' Create a regular expression object.
       Set objRegExp = New RegExp

       ''Set the pattern by using the Pattern property.
       objRegExp.Pattern = myPattern

       '' Set Case Insensitivity.
       objRegExp.IgnoreCase = True

       ''Set global applicability.
       objRegExp.Global = True

       ''Test whether the String can be compared.
       If (objRegExp.Test(myString) = True) Then

       ''Get the matches.
        Set colMatches = objRegExp.Execute(myString)   '' Execute search.

        For Each objMatch In colMatches   '' Iterate Matches collection.
          RetStr = RetStr & "Match found at position "
          RetStr = RetStr & objMatch.FirstIndex & ". Match Value is ''"
          RetStr = RetStr & objMatch.Value & "''." & vbCrLf
        Next
       Else
        RetStr = "String Matching Failed"
       End If
       TestRegExp = RetStr
    End Function

    10. 在“運行”菜單上,單擊“啟動”來運行該應用程序。
    11. 單擊“Command1”。

    此時將出現一個消息框,該消息顯示 IS1 is2 IS3 is4 字符串中的所有 is 匹配項。

    延伸閱讀

    文章來源于領測軟件測試網 http://www.kjueaiud.com/


    關于領測軟件測試網 | 領測軟件測試網合作伙伴 | 廣告服務 | 投稿指南 | 聯系我們 | 網站地圖 | 友情鏈接
    版權所有(C) 2003-2010 TestAge(領測軟件測試網)|領測國際科技(北京)有限公司|軟件測試工程師培訓網 All Rights Reserved
    北京市海淀區中關村南大街9號北京理工科技大廈1402室 京ICP備10010545號-5
    技術支持和業務聯系:info@testage.com.cn 電話:010-51297073

    軟件測試 | 領測國際ISTQBISTQB官網TMMiTMMi認證國際軟件測試工程師認證領測軟件測試網

    老湿亚洲永久精品ww47香蕉图片_日韩欧美中文字幕北美法律_国产AV永久无码天堂影院_久久婷婷综合色丁香五月

  • <ruby id="5koa6"></ruby>
    <ruby id="5koa6"><option id="5koa6"><thead id="5koa6"></thead></option></ruby>

    <progress id="5koa6"></progress>

  • <strong id="5koa6"></strong>