VBS tutorial: object matches collection


Matches set

regular expression MatchA collection of objects.


MatchesThe collection contains several independentMatchObject, can only be usedRegExpObjectExecuteMethod to create it. And independentMatchObject properties are the same,Matches`A property of the collection is read-only.

When a regular expression is executed, it may produce zero or moreMatchObject. eachMatchObjects provide access to the string matching the regular expression, the length of the string, and an index identifying the matching location.

The following code shows how to use regular expression lookup to getMatchesSet, and how to loop through the set:

Function RegExpTest(patrn, strng)  Dim regEx, Match, Matches       '  Create variables. Set regEx = New RegExp          '  Create regular expressions. regEx.Pattern = patrn          '  Set the mode. regEx.IgnoreCase = True          '  Sets whether the is case sensitive. regEx.Global = True          '  Set full match. Set Matches = regEx.Execute(strng)    '  Perform a search. For Each Match in Matches       '  Loop through the matches collection. RetStr = RetStr & "Match found at position "    RetStr = RetStr & Match.FirstIndex & ". Match Value is '"    RetStr = RetStr & Match.Value & "'." & vbCRLF  Next  RegExpTest = RetStrEnd FunctionMsgBox(RegExpTest("is.", "IS1 is2 IS3 is4"))

Recommended Today

Sort out recently used Mongo query statements

background Recently, I have made several rule logic. Mongo query is often used, which is to query transaction information, run established rules to screen out trading merchants, use aggregation pipeline for statistics and take out simple processed data, and use SQL instead of business code logic judgment. method Mongodb aggregation usageaggregate, the aggregation pipeline adopts […]