REGULAR EXPRESSIONS - identify specific entries as INVALID

S

Skinnerfritz

Hey all,

I'm looking for some help on coding a validationexpression of regular
expression validation control in C#.

The problem is simple..and it would seem the solution likely is as well.
But I haven't come up with it.

I'd like to validatie a textbox entry.

The entry must be 6 digits. And must NOT equal any of the following four
values : 110500, 101100, 109900, 101007.

I've tried a number of things to no avail. So I won't limit any of your
collective potential solutions with the novice suggestions I've tried.

Thanks in advance!!
 
D

David Craig

We don't do drivers in C#. Only Singularity does and it is just a Microsoft
research project released on SourceForge.

P.S. Do your own homework.
 
S

Skinnerfritz

With all due respect the drivers that you mention are irrelevant to the
Validationexpression property of the regular expression validation control.

The formats I've been looking at are things such as:
/d6 (?!110500|101100)
(?>110500|101100)
(?!(110500$))
etc..

The question is syntactical in nature.

Though I do apologize for posting it in the device.drivers forum.
 
G

Göran Andersson

Skinnerfritz said:
Hey all,

I'm looking for some help on coding a validationexpression of regular
expression validation control in C#.

The problem is simple..and it would seem the solution likely is as well.
But I haven't come up with it.

I'd like to validatie a textbox entry.

The entry must be 6 digits. And must NOT equal any of the following four
values : 110500, 101100, 109900, 101007.

I've tried a number of things to no avail. So I won't limit any of your
collective potential solutions with the novice suggestions I've tried.

Thanks in advance!!

Use a negative look-ahead:

(?!110500)(?!101100)(?!109900)(?!101007)\d{6}
 
C

chris.aseltine

I'd like to validatie a textbox entry.

The entry must be 6 digits. And must NOT equal any of the following four
values : 110500, 101100, 109900, 101007.

Why would you use a regular expression for this?

Set<int> invalidSet = new Set<int>();
invalidSet.Add(110500);
invalidSet.Add(101100);
invalidSet.Add(109900);
invalidSet.Add(101007);

int val = Convert.ToInt32(textBox.Text);
if (!invalidSet.Contains(val))
{
// ....
}
 

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

Members online

Forum statistics

Threads
473,772
Messages
2,569,588
Members
45,100
Latest member
MelodeeFaj
Top