Collection: MatchCollection
- Mise à jour2024-09-12
- Temps de lecture : 1 minute(s)
Collection: MatchCollection
Collection of all Matches when searching a character string with a regular expression.
The following example checks whether the given character string contains the text pattern and returns all positions of the matches:
Function FindPattern(sPattern, sText) Dim RegExpression, Matches, Match, ResText Set RegExpression = CreateObject("VBScript.RegExp") RegExpression.Pattern = sPattern RegExpression.Global = True RegExpression.MultiLine = True Set Matches = RegExpression.Execute(sText) For Each Match in Matches ResText = ResText & "Match at " & Match.FirstIndex & vbCRLF Next FindPattern = ResText End Function