REgular expression validation

Discussion in 'ASP .Net' started by =?Utf-8?B?Y2xpY2tvbg==?=, Apr 7, 2006.

  1. I am using a RegularExpressionValidator to validate against a range on
    specific values and it is behaving strangely. My validation expression is as
    follows

    ^001|100|101|101D|102|103|103D|110|110D|111|112|113|114|114D|115|115D|116|117|117D|118|118D|119|120|120D|121|124|126|126D|127|127D|128|128D|129|129D|130|130D|131|131D|132|132D|600|610|611|612|613|613D|616|661|711|712|712D|118D$

    Which are a series of valid product codes. It validates correctly against
    all of the codes that are just numbers, but it does not validate against the
    codes that contain a D at the end.

    e.g.

    It is happy with 001, 100 or 101 but it says 104 is invalid, which is as it
    should be. Byt when i enter 110D then it says it is not valid even though it
    is in the validation expresion.
     
    =?Utf-8?B?Y2xpY2tvbg==?=, Apr 7, 2006
    #1
    1. Advertising

  2. Regular Expressions consume the strings they match, character by character.
    Since you put "110" before "110D", "110" will always be consumed as a match
    before the opportunity to find the "D" occurs. To fix, this, simply reverse
    the order of items which contain other items. For example:

    110|110D should be 110D|110
    118|118D should be 118D|118

    --
    HTH,

    Kevin Spencer
    Microsoft MVP
    Professional Numbskull

    Show me your certification without works,
    and I'll show my certification
    *by* my works.

    "clickon" <> wrote in message
    news:...
    >I am using a RegularExpressionValidator to validate against a range on
    > specific values and it is behaving strangely. My validation expression is
    > as
    > follows
    >
    > ^001|100|101|101D|102|103|103D|110|110D|111|112|113|114|114D|115|115D|116|117|117D|118|118D|119|120|120D|121|124|126|126D|127|127D|128|128D|129|129D|130|130D|131|131D|132|132D|600|610|611|612|613|613D|616|661|711|712|712D|118D$
    >
    > Which are a series of valid product codes. It validates correctly against
    > all of the codes that are just numbers, but it does not validate against
    > the
    > codes that contain a D at the end.
    >
    > e.g.
    >
    > It is happy with 001, 100 or 101 but it says 104 is invalid, which is as
    > it
    > should be. Byt when i enter 110D then it says it is not valid even though
    > it
    > is in the validation expresion.
     
    Kevin Spencer, Apr 7, 2006
    #2
    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. Mark
    Replies:
    3
    Views:
    10,025
  2. VSK
    Replies:
    2
    Views:
    2,355
  3. Nazir
    Replies:
    3
    Views:
    5,104
    jayendra gadhavi
    Jan 2, 2008
  4. =?iso-8859-1?B?bW9vcJk=?=

    Matching abitrary expression in a regular expression

    =?iso-8859-1?B?bW9vcJk=?=, Dec 1, 2005, in forum: Java
    Replies:
    8
    Views:
    873
    Alan Moore
    Dec 2, 2005
  5. GIMME
    Replies:
    3
    Views:
    12,025
    vforvikash
    Dec 29, 2008
Loading...

Share This Page