O'Reilly logo

VBScript in a Nutshell, 2nd Edition by Ron Petrusha, Matt Childs, Paul Lomax

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Name

RegExp Object

Description

The RegExp object provides support for regular expression matching—for the ability to search strings for substrings matching general or specific patterns.

In order to conduct a pattern search, you must first instantiate the regular expression object, with code like the following:

Dim oRegExp             ' Instance of RegExp object 
Set oRegExp = New RegExp

To conduct a search using the RegExp object, do the following:

  • Determine whether the search should be case-sensitive.

  • Determine whether all instances or just the first instance of the substring should be returned.

  • Supply the pattern string that you want to find.

  • Provide a string that the RegExp object is to search.

The RegExp object allows you to search for a substring that matches your pattern string in any of three ways:

  • You can determine whether a pattern match is found in the string.

  • You can return one or all of the occurrences of the matching substrings. In this case, results are returned in Match objects within the Matches collection.

  • You can replace all substrings matching the pattern string with another string.

Properties

The RegExp object supports the three properties shown in the following table. Each is documented in depth in its own section in the Language Reference.

Property name

Description

Global

Indicates whether to search for all occurrences of the pattern string or just for the first one

IgnoreCase

Indicates whether the pattern search is case-sensitive

Pattern

Indicates the pattern string to search for

Methods

The ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required