DIAdem Help

Object: Match

  • Updated2024-09-12
  • 1 minute(s) read

Object: Match

The Match object provides a match when searching with a regular expression in a character string. You can only create a Match object with the Execute method. The result of this method is a MatchCollection collection that contains Match objects.

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

Properties

FirstIndex | Length | SubMatches | Value