Help with regular expression

  • Thread starter Thread starter hillcountry74
  • Start date Start date
H

hillcountry74

Hi,

I'm stuck with this regular expression from past 2 days. Desperately
need help.

I need a regular expression that will allow all characters except these
*:~<>'

This is my code in VB.Net-
Dim regex As System.Text.RegularExpressions.Regex
regex = New System.Text.RegularExpressions.Regex("^[^*:~<>']*$")
It matches for most of the test cases except when I enter <mno or mn<vb
it throws an exception- "A potentially dangerous Request.Form value was
detected from the client (txtregex="<vb"). "

How I get around this? Please help.

Thanks a lot.
 
hillcountry74 said:
I'm stuck with this regular expression from past 2 days. Desperately
need help.

I need a regular expression that will allow all characters except these
*:~<>'

This is my code in VB.Net-
Dim regex As System.Text.RegularExpressions.Regex
regex = New System.Text.RegularExpressions.Regex("^[^*:~<>']*$")
It matches for most of the test cases except when I enter <mno or mn<vb
it throws an exception- "A potentially dangerous Request.Form value was
detected from the client (txtregex="<vb"). "

How I get around this? Please help.

I don't believe it's your regular expression which is the problem
(although I'd expect the first * to be escaped; maybe it doesn't have
to be in this case). It's ASP.NET itself which is rejecting the
submission. You can disable request validation using
validateRequest="false" in your Page directive. See
http://www.asp.net/faq/RequestValidation.aspx
for more information.
 
Jon,

Thanks a lot. That was really helpful. Now after doing
HtmlEncode/HTMDecode, it works fine.
 
Back
Top