Name

RegExp.Execute Method

Syntax

RegExp.Execute(string)
string

Use: Required

Data Type: String

The string to be searched.

Return Value

A Matches collection containing one or more Match objects.

Description

Performs a regular expression search against string and returns the results in the Matches collection.

Rules at a Glance

  • The method searches string using the RegExp object’s Pattern property.

  • The results are returned in the Matches collection, which is a collection of Match objects.

  • If the search finds no matches, the Matches collection is empty.

Programming Tips and Gotchas

  • Remember to use the Set statement to assign the Matches collection returned by the Execute method to an object variable.

  • You can determine whether the Matches collection returned by the Execute method is empty by examining its Count property. It is empty if the value of Count is 0.

Example

See the example for the RegExp.Pattern Property.

Get VBScript in a Nutshell, 2nd Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.