- REGULAR EXPRESSIONS - identify specific entries as INVALID
- Posted by Skinnerfritz on June 20th, 2008
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!!
- Posted by David Craig on June 20th, 2008
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.
"Skinnerfritz" <Skinnerfritz@discussions.microsoft.com> wrote in message
news:8EDBE4E3-1838-456A-B9FB-28C54D737E0E@microsoft.com...
- Posted by Skinnerfritz on June 20th, 2008
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.
"David Craig" wrote:
- Posted by Göran Andersson on June 20th, 2008
Skinnerfritz wrote:
Use a negative look-ahead:
(?!110500)(?!101100)(?!109900)(?!101007)\d{6}
--
Göran Andersson
_____
http://www.guffa.com
- Posted by Skinnerfritz on June 20th, 2008
Works perfectly.
Thanks so much, Goran.
"Göran Andersson" wrote:
- Posted by chris.aseltine@gmail.com on June 20th, 2008
On Jun 20, 10:07 am, Skinnerfritz
<Skinnerfr...@discussions.microsoft.com> wrote:
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))
{
// ....
}