Need help with regular expression.

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.
 
K

Ken Tucker [MVP]

Hi,

This should work for you. If the string contains the charcters ismatch
will return true


Dim rMatch As New System.Text.RegularExpressions.Regex("[*:~<>']")
TextBox1.Text = (rMatch.IsMatch("<mno")) & vbCrLf
TextBox1.Text &= (rMatch.IsMatch("x is less than y")) & vbCrLf
TextBox1.Text &= (rMatch.IsMatch("mn<vb"))


Ken
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top