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.
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.
Indicates whether to search for all occurrences of the pattern string or just for the first one
Indicates whether the pattern search is case-sensitive
Indicates the pattern string to search for