[thelist] ASP - Regular Expressions

Joshua Olson joshua at waetech.com
Tue Aug 5 08:20:08 CDT 2003

----- Original Message ----- 
From: <burgan at iprimus.com.au>
Sent: Tuesday, August 05, 2003 3:20 AM

> I don't want the user to be able to input '--text' or 'text--' but able to
input 'te-xt'.


I'm not sure that you've fully explained the validation that you're looking
for, but I'm going to assume the following for a moment--You want to allow
all strings that have at least one alpha, followed by exactly one hyphen,
followed by at least one more alpha.

If so, here is a usable regex:


Here's the breakdown:

^   start of line
[a-zA-Z]+   One or more alphabetic characters
-   the literal hyphen character
[a-zA-Z]+   One or more alphabetic characters
$   end of line

Here's a good reference:



Joshua Olson
Web Application Engineer
WAE Tech Inc.

More information about the thelist mailing list