In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-17 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)06/03 Report--
This article mainly shows you "how to use regular expressions in VB", the content is easy to understand, clear, hope to help you solve doubts, the following let Xiaobian lead you to study and learn "how to use regular expressions in VB" this article.
1. Start Microsoft Visual Basic 6. 0.
two。 On the File menu, click New Project.
3. In the New Project dialog box, click Standard Exe, and then click OK.
A Form1 is created by default.
4. On the Project menu, click reference.
5. Double-click Microsoft VBScript Regular Expressions 5.5, and then click OK.
6. In the toolbox, double-click the Command button.
By default, "Command1" is added to the form.
7. Double-click "Command1" to open the code window.
8. Paste the following into the "Command1_Click" event handler: MsgBox (TestRegExp ("is.", "IS1 is2 IS3 is4"))
Note that in this example, the is. IS1 is2 IS3 is4 is checked against the "is" string. Mode. You can change the special character of the period (.) Used as a wildcard so that the search pattern can match and display one more character. If www.x-force.cn you add two periods to the search mode, you will see two other characters. If you do not use any periods, you will only see the search pattern.
9. After adding the following functions to the "Command1_click" event handler:
[codes=vb] 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 [/ codes]
10. On the run menu, click start to run the application.
11. Click Command1.
A message box appears showing all is matches in the IS1 is2 IS3 is4 string.
The above is all the content of the article "how to use regular expressions in VB". Thank you for reading! I believe we all have a certain understanding, hope to share the content to help you, if you want to learn more knowledge, welcome to follow the industry information channel!
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.