Velocity Reviews

Velocity Reviews (http://www.velocityreviews.com/forums/index.php)
-   ASP .Net (http://www.velocityreviews.com/forums/f29-asp-net.html)
-   -   REGULAR EXPRESSIONS - identify specific entries as INVALID (http://www.velocityreviews.com/forums/t621366-regular-expressions-identify-specific-entries-as-invalid.html)

Skinnerfritz 06-20-2008 03:07 PM

REGULAR EXPRESSIONS - identify specific entries as INVALID
 
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!!



David Craig 06-20-2008 04:27 PM

Re: REGULAR EXPRESSIONS - identify specific entries as INVALID
 
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...
> 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!!
>
>




Skinnerfritz 06-20-2008 05:20 PM

Re: REGULAR EXPRESSIONS - identify specific entries as INVALID
 

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:

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

>
>
>


Göran Andersson 06-20-2008 05:29 PM

Re: REGULAR EXPRESSIONS - identify specific entries as INVALID
 
Skinnerfritz wrote:
> 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}

--
Göran Andersson
_____
http://www.guffa.com

Skinnerfritz 06-20-2008 05:42 PM

Re: REGULAR EXPRESSIONS - identify specific entries as INVALID
 
Works perfectly.

Thanks so much, Goran.


"Göran Andersson" wrote:

> Skinnerfritz wrote:
> > 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}
>
> --
> Göran Andersson
> _____
> http://www.guffa.com
>


chris.aseltine@gmail.com 06-20-2008 07:27 PM

Re: REGULAR EXPRESSIONS - identify specific entries as INVALID
 
On Jun 20, 10:07 am, Skinnerfritz
<Skinnerfr...@discussions.microsoft.com> wrote:

> 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))
{
// ....
}


All times are GMT. The time now is 04:36 AM.

Powered by vBulletin®. Copyright ©2000 - 2014, vBulletin Solutions, Inc.
SEO by vBSEO ©2010, Crawlability, Inc.