[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'.

Tim,

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:

^[a-zA-Z]+-[a-zA-Z]+$

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:

http://www.evolt.org/article/Regular_Expression_Basics/20/22700/index.html

HTH,

<><><><><><><><><><>
Joshua Olson
Web Application Engineer
WAE Tech Inc.
http://www.waetech.com
706.210.0168



More information about the thelist mailing list