[thelist] ASP - Regular Expressions

burgan at iprimus.com.au burgan at iprimus.com.au
Tue Aug 5 02:20:29 CDT 2003

Hi all (again),

I'm using the following regular expression within a function to validate some form fields.

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

At the moment this is working properly for everything but 'text--'. It still allows the user to do this. I don't really know why except that it relates to the $ sign, because I first read about regular expressions today. 

I'd appreciate any help.
Also will this prevent SQL Injections, or will I need to add extra to it??


  Function IsValidChar(strData)
    Dim objRegExpr
    Set objRegExpr = New RegExp

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

    strData = objRegExpr.Replace(strData, "")

    IsValidChar = objRegExpr.Test(strData)
    Set objRegExpr = Nothing
  End Function

mail2web - Check your email from the web at

More information about the thelist mailing list