July 7, 2001

Extract all quoted strings with the RegExp object

When parsing a text file that contains quoted strings – such as a VB source file – you might want to quickly locate and extract all the quoted strings. Thanks to regular expressions and the RegExp object in the Microsoft VBScript Regular Expression type library, this task is surprisingly easy:

Create a better InStr function with VBScript regular expressions

Regular expressions offer an extremely powerful way to search and replace text inside a string using sophisticated search criteria, far behind the capabilities of VB’s InStr and Replace functions. For example, you can search for whole words, or find a match with a range of characters (for example, a digit

Count number of words with the RegExp object

A Visual Basic function that counts the number of words in a sentence or text file can become quickly very complex, and usually doesn’t execute fast enough for most purposes. Thanks to the RegEx object that comes with the Microsoft VBScript Regular Expression type library, this task becomes trivial. Here’s

Extract words with the RegExp object

The following routine extracts all the words from a source string and returns a collection. Optionally, the result contains only unique words.This code is remarkably simpler than an equivalent “pure” VB solution because it takes advantage of the RegExp object in the Microsoft VBScript Regular Expression type library. ‘ Get