REGULAR EXPRESSIONS - identify specific entries as INVALID

Discussion in 'ASP .Net' started by Skinnerfritz, Jun 20, 2008.

  1. Skinnerfritz

    Skinnerfritz Guest

    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, Jun 20, 2008
    #1
    1. Advertising

  2. Skinnerfritz

    David Craig Guest

    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" <> wrote in message
    news:...
    > 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, Jun 20, 2008
    #2
    1. Advertising

  3. Skinnerfritz

    Skinnerfritz Guest

    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" <> wrote in message
    > news:...
    > > 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, Jun 20, 2008
    #3
  4. 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
    Göran Andersson, Jun 20, 2008
    #4
  5. Skinnerfritz

    Skinnerfritz Guest

    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
    >
    Skinnerfritz, Jun 20, 2008
    #5
  6. Skinnerfritz

    Guest

    On Jun 20, 10:07 am, Skinnerfritz
    <> 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))
    {
    // ....
    }
    , Jun 20, 2008
    #6
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Jay Douglas
    Replies:
    0
    Views:
    601
    Jay Douglas
    Aug 15, 2003
  2. Tony C
    Replies:
    6
    Views:
    323
  3. Don Bruder
    Replies:
    3
    Views:
    970
    spikeysnack
    Aug 3, 2010
  4. Skinnerfritz

    REGULAREXPRESSION - identify specific value(s) as INVALID

    Skinnerfritz, Jun 20, 2008, in forum: ASP .Net Web Controls
    Replies:
    1
    Views:
    108
    Skinnerfritz
    Jun 20, 2008
  5. Noman Shapiro
    Replies:
    0
    Views:
    232
    Noman Shapiro
    Jul 17, 2013
Loading...

Share This Page