DIAdem Help

Method: Execute for RegExp

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

Method: Execute for RegExp

Uses a regular expression to search in a character string and returns a collection that contains every match found in the character string.

Set oDispatch = Object.Execute(sourceString)
ObjectRegExp
Object with this method
sourceStringString
Specifies the character string you want to search through. 
oDispatchMatchCollection
Returned object

The following example checks whether the given character string contains the text pattern:

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