Jump to content

Regular Expression Error


kwilliams

Recommended Posts

I'm trying to use regular expressions in my ASP.NET doc, and I'm running into a problem. This is how I've set it up:

<%@ import Namespace="System.Text.RegularExpressions" %><%'Validate form data - required fields onlyDim RegularExpressionObject As Object  RegularExpressionObject = New RegExp  	With RegularExpressionObject	.Pattern = "[A-Za-z0-9]"	.IgnoreCase = True	.Global = TrueEnd With%>

And this is the error that I'm receiving:Compilation ErrorType 'RegExp' is not defined.Line 77: Dim RegularExpressionObject As ObjectLine 78: Line 79: RegularExpressionObject = New RegExpLine 80: Line 81: With RegularExpressionObjectIf anyone can give me some advice on my I'm getting this error message, it would be greatly appreciated. Thanks.

Link to comment
Share on other sites

I guess you are checking not to allow special characters, try this code.Dim regExp As Regex Dim regMatch As Match regExp = New Regex("[A-Za-z0-9]") dim str as string="%" regMatch = regExp.Match(str) If (regMatch.Success And regMatch.Value = str) Then Response.Write("Success") Else Response.Write("Failed") End If

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...