[thelist] ASP - Regular Expressions

Hassan Schroeder hassan at webtuitive.com
Tue Aug 5 12:37:09 CDT 2003


burgan at iprimus.com.au wrote:

> By the way i'm trying to make entries like "--text" and "text--" return
> false.. but i'm also trying to make "-text" and "text-" return FALSE.
> 
> Code like "t-ext" or "te-xt" etc is what I want to return TRUE.

This really isn't that complex :-)

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

starts (^) with one or more (+) alpha characters
	followed by one literal `-` character
		followed by one or more (+) alpha characters
			end of string ($)

By comparison, this example of yours

objRegExpr.Pattern = "^[a-zA-Z]*[\-]*[a-zA-Z]$"

starts with zero or more alpha characters (that matches *any* string)
	followed by zero or more `-` characters (ditto)
		exactly one alpha character
			end of string
HTH!
-- 
Hassan Schroeder ----------------------------- hassan at webtuitive.com
Webtuitive Design ===  (+1) 408-938-0567   === http://webtuitive.com

                           dream.  code.





More information about the thelist mailing list