REGULAR EXPRESSIONS - identify specific entries as INVALID

  • Thread starter Thread starter Skinnerfritz
  • Start date Start date
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!!
 
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.
 
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.
 
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}
 
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))
{
// ....
}
 
Back
Top