By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
434,882 Members | 2,273 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 434,882 IT Pros & Developers. It's quick & easy.

Help with regular expression

P: n/a
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.

Sep 21 '05 #1
Share this Question
Share on Google+
2 Replies


P: n/a
hillcountry74 <sh*******@yahoo.com> wrote:
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 Skeet - <sk***@pobox.com>
http://www.pobox.com/~skeet Blog: http://www.msmvps.com/jon.skeet
If replying to the group, please do not mail me too
Sep 21 '05 #2

P: n/a
Jon,

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

Sep 21 '05 #3

This discussion thread is closed

Replies have been disabled for this discussion.