偷偷摘套内射激情视频,久久精品99国产国产精,中文字幕无线乱码人妻,中文在线中文a,性爽19p

在VB中如何使用正則表達式

開發(fā) 后端
這里我們要談到如何在Visual Basic 6.0中使用正則表達式,希望對大家有所幫助。

1. 啟動 Microsoft Visual Basic 6.0。

2. 在“文件”菜單上,單擊“新建項目”。

3. 在“新建項目”對話框中,單擊“Standard Exe”,然后單擊“確定”。

默認情況下將創(chuàng)建 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. 模式。您可以將句點這一特殊字符(.)用作通配符,這樣,搜索模式就能夠多匹配并多顯示一個字符。如果www.x-force.cn您在搜索模式中添加兩個句點,您會看到兩個其他字符。如果您不使用任何句點,您只會看到搜索模式。

9. 將以下函數添加到“Command1_click”事件處理程序后:

  1. [codes=vb]Function TestRegExp(myPattern As String, myString As String)  
  2. ”Create objects.  
  3. Dim objRegExp As RegExp  
  4. Dim objMatch As Match  
  5. Dim colMatches As MatchCollection  
  6. Dim RetStr As String 
  7. ” Create a regular expression object.  
  8. Set objRegExp = New RegExp  
  9. Set the pattern by using the Pattern property.  
  10. objRegExp.Pattern = myPattern  
  11. ” Set Case Insensitivity.  
  12. objRegExp.IgnoreCase = True 
  13. Set global applicability.  
  14. objRegExp.Global = True 
  15. ”Test whether the String can be compared.  
  16. If (objRegExp.Test(myString) = TrueThen 
  17. Get the matches.  
  18. Set colMatches = objRegExp.Execute(myString) ” Execute search.  
  19. For Each objMatch In colMatches ” Iterate Matches collection.  
  20. RetStr = RetStr & “Match found at position “  
  21. RetStr = RetStr & objMatch.FirstIndex & “. Match Value is ””  
  22. RetStr = RetStr & objMatch.Value & “”.” & vbCrLf  
  23. Next 
  24. Else 
  25. RetStr = “String Matching Failed”  
  26. End If 
  27. TestRegExp = RetStr  
  28. End Function[/codes] 

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

11. 單擊“Command1”。

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

原文鏈接:http://www.cnblogs.com/caiy007/archive/2012/05/08/2489553.html

責任編輯:彭凡 來源: 博客園
相關推薦

2010-03-25 18:25:36

Python正則表達式

2009-06-15 17:24:59

Groovy正則表達式

2009-09-16 17:29:30

正則表達式使用詳解

2018-09-27 15:25:08

正則表達式前端

2009-03-16 14:01:24

正則表達式函數SQL

2020-09-04 09:16:04

Python正則表達式虛擬機

2010-01-07 13:29:00

VB.NET正則表達式

2023-10-07 08:25:09

Java處理工具正則表達式

2024-12-25 15:09:38

Python字符串函數

2024-09-14 09:18:14

Python正則表達式

2021-05-25 09:18:04

正則表達式Linux字符串

2009-10-26 16:12:19

VB.NET正則表達式

2018-04-21 07:11:53

正則表達式Python函數

2022-03-28 06:19:14

正則表達式開發(fā)

2021-01-27 11:34:19

Python正則表達式字符串

2009-02-18 09:48:20

正則表達式Java教程

2019-07-17 15:45:47

正則表達式字符串前端

2009-09-16 18:19:34

正則表達式組

2011-06-02 12:34:16

正則表達式

2017-05-12 10:47:45

Linux正則表達式程序基礎
點贊
收藏

51CTO技術棧公眾號