Regular Expressions (RegExp)

VBScript now supports regular expressions through a new intrinsic VBScript object: RegExp. VBScript developers can instantiate a RegExp object and use it to evaluate string data against pattern, which is a kind of shorthand description of how a string of data might look. For example, the pattern "\w+\@[.\w]+" checks to see if a string looks like an e-mail address. Regular expression patterns are are obviously rather strange looking, and can take some getting used to. However, regular expressions are a powerful way to check the validity of data (for instance, to see if your user entered a properly formatted e-mail address), or to search for all kinds of strings in text files or other text-based data.

The pattern syntax in the VBScript RegExp object is exactly the same as in JavaScript, which is in turn based on Perl regular expressions. JavaScript has supported regular expressions for a while, and adding this powerful feature to VBScript is Microsoft's fulfillment of a promise to keep VBScript and JavaScript 'in synch' feature-for-feature.

First
Next