VBScriptNovice
Last month, I introduced you to VBScript's regular expressions. This month, I present handy code that you can use to enhance your real-world VBScript applications. Specifically, I show you how to use regular expressions to rewrite two commonly used VBScript functions: InputBox and Replace. You can use the rewritten InputBox function to create dialog boxes that accept only data that matches a regular expression you specify. You can use the rewritten Replace function to perform powerful search-and-replace operations.
Rewriting the InputBox Function
In the Web-exclusive sidebar "Building a Better InputBox Function" in my October 1999 column, I created an improved version of the InputBox function called InputBoxEx. This user-defined function not only produced a dialog box but also validated the data users entered in it. You can use parts of the InputBoxEx code to create a function called InputBoxRegEx. This new user-defined function produces a dialog box, then determines whether the entered text matches the specified regular expression pattern. . . .