Thanks for response. Let me give more details. The valid format should be either numbers such as 10, 20, 30 or a range consisting of one number, a hyphen (-) and a second number. For example, 1-2 is fine. 10-200 is OK. 1000-7367 is also OK. Help please!!!!!! The project is due!!!

解决方案 »

  1.   

    string reg=@"^(([1][0-9])|(20))$";
      

  2.   

    你的英语很厉害啊
    我能跟你学英语吗?
    Regular expression 我也不熟
      

  3.   

    try
    @"^([1-9][0]{1,}-[1-9]{0,}|[1-9]-[0-9]{0,})$"
      

  4.   

    ^([1-9][0]{1,}-[1-9]{1}[0-9]{0,}|[1-9]-[0-9]{0,})$
    10-200  is ok
    10000-345345 is ok
    1-996 is ok
    ......
      

  5.   

    留下你的e-mail,我发个正则的文档给你,就比较清楚了
      

  6.   

    我也需要文档,谢谢hychieftain(不同)。
    [email protected]
      

  7.   

    [email protected]
    顺便给我份 谢谢
      

  8.   

    xiahouwen(活靶子.NET). Thank you very much for your great help. But the RE doesn' t accept the single numbers such as 89, 670, 2435. I want the ideal validator to verify not only a interger range but also interger numeric values. Any idea? Regarding English, I would suggest you to read CNN or any other news more frequently.
     hychieftain(不同) . Thank you very much for the document in advance. Please send it to my email account: [email protected]
    Thank the other guys very much for your help and time.
      

  9.   

    About the single numbers you can add "[1-9]{0,}|" in the Regx@"^([1-9]{0,}|[1-9][0]{1,}-[1-9]{1}[0-9]{0,}|[1-9]{0,}-[0-9]{0,})$"it accept 132,222,123-888,100-800 ... Regards,
    Huo ba zi
      

  10.   

    已发送,请接收!!
    to  mumuhope(hopehaha)
    希望向你学习英语!! ^_^
      

  11.   

    再给你一个正则的好网站
    http://www.regexlib.com/
      

  12.   

    Please Help ! I don't have much time to study RE now. I copy the code upstairs and use it in my code, but it won't accept both numbers and ranges.Here is the source code. Is there anything wrong with the code?  Thanks a lot for your help in advance. <asp:TableRow ID="tbrMIDuration">
    <asp:TableCell Text="Duration (IEP)"></asp:TableCell>
    <asp:TableCell BackColor="WhiteSmoke">
    <asp:TextBox ID="tbMIDuration" Runat="server"></asp:TextBox>
    <asp:DropDownList ID="dlMIDuration" Runat="Server"></asp:DropDownList>
    <asp:RegularExpressionValidator ID="rvMIDuration" Runat="server" ErrorMessage="<BR>Invalid Duration value (example: 10 or 10-20)"
    ControlToValidate="tbMIDuration" ValidationExpression=@"^([1-9]{0,}|[1-9][0]{1,}-[1-9]{1}[0-9]{0,}|[1-9]{0,}-[0-9]{0,})$" Display="Dynamic"></asp:RegularExpressionValidator>
    </asp:TableCell>
    </asp:TableRow>
      

  13.   

    I already solved the problem by following one example. Here is the code. Does anybody know how to check the range is a valid range? For example, I got a range A-B. Is there any way such as javascript to check whether A is greater than B? I don't know how to hook up a javascript function into the code. Help please.
    <asp:TableRow ID="tbrMIDuration">
    <asp:TableCell Text="Duration (IEP)"></asp:TableCell>
    <asp:TableCell BackColor="WhiteSmoke">
    <asp:TextBox ID="tbMIDuration" Runat="server" ></asp:TextBox>
    <asp:DropDownList ID="dlMIDuration" Runat="Server"></asp:DropDownList>
    <asp:RegularExpressionValidator ID="rvMIDuration" Runat="server" ErrorMessage="<BR>Invalid Duration value (example: 10 or 10-20)"
    ControlToValidate="tbMIDuration" ValidationExpression="\d+(-\d+)?" Display="Dynamic"></asp:RegularExpressionValidator>
    </asp:TableCell>