Regular Expressions in Classic ASP

The VBScript RegExp object can test whether a string matches a required pattern. In Classic ASP this is useful for validating the shape of values such as user IDs or email addresses before further processing.

Pattern validation is only one layer of security. It does not replace prepared/parameterized database commands, output encoding, authorization checks, or business-rule validation.

Create a RegExp object

Dim re
Set re = New RegExp
re.IgnoreCase = True
re.Global = False

Set Pattern to the rule you want to test, then call Test(value). For validation, anchoring the expression with ^ and $ usually ensures the whole value is checked rather than just a matching substring.

What regular expressions are good for

  • Restricting a user ID to an expected character set and length.
  • Checking that a value has a plausible email-address format.
  • Recognizing structured codes such as ZIP/postal formats when the application has a clearly defined rule.

Do not use a very restrictive pattern when valid real-world input is more varied than the pattern allows. Validate only what the application genuinely requires.


ASP Home






✖
We use cookies to improve your browsing experience. . Learn more
HTML MySQL PHP JavaScript ASP Photoshop Articles Contact us
© 2000-2026 plus2net.com All rights reserved worldwide Privacy Policy Disclaimer