VBScript lacks an operator to match strings against a given pattern. VBScript's predecessor, Visual Basic for Applications (VBA), offers this feature in the form of the Like operator. You use VBA's Like operator with code such as

                              A = ""                              B = "*.com"                              MsgBox A Like B                              

The Like operator accepts a string as the first argument and the pattern to match as the second argument. For example, "*.com" means that you want to match any strings that end with .com. This operator is really useful when you're working with filenames and regular strings.

I've created a VBScript function, which I call the IsLike function, that simulates the Like operator. The IsLike function takes a string and the pattern as arguments and returns a Boolean value. Listing A contains this function. On the Win32 Scripting Journal Web site, Listing A includes comments explaining how this function works line by line. The .zip file containing Listing A also includes example code showing how you might use the IsLike function in a script. For more information about the IsLike function, see Dino Esposito, Windows Script Host Programmer's Reference (Wrox Press, 1999).