Got more questions? Find advice on: ASP | SQL | XML | Windows
in Search
Welcome to RegexAdvice Sign in | Join | Help

Need Reg expression for Numbers between 5 and 110

Last post 05-13-2008, 3:54 PM by mash. 3 replies.
Sort Posts: Previous Next
  •  05-13-2008, 1:23 PM 42194

    Need Reg expression for Numbers between 5 and 110

    Hi,

     I'm in need of a regular expression to use in a validation control that checks that the user input a correct range of values in the textboxes.  The expression I need would allow only positive integers between 5 and 110 to be entered.  I currently used the below expression which has failed, as it accepts anything from 0 to 110:

     ^((110)|(\d{0,2}))$

    Can someone help me out with correcting that expression?

     Thanks!

  •  05-13-2008, 1:58 PM 42198 in reply to 42194

    Re: Need Reg expression for Numbers between 5 and 110

    ^([5-9]|[1-9]\d|10\d|110)$
  •  05-13-2008, 3:11 PM 42202 in reply to 42198

    Re: Need Reg expression for Numbers between 5 and 110

    Much appreciated, thanks!!  You might want to consider adding your expression to the library since there is none that select postive numbers between a range of values. (no decimals)
  •  05-13-2008, 3:54 PM 42204 in reply to 42202

    Re: Need Reg expression for Numbers between 5 and 110

    Using a regex to select a numeric range is not the best application of a regex, unless the range is fixed and not likely to change.  Depending on the range the patterns can get pretty ugly and are not very flexible and can become awkward to adjust.

    Michael

    "In theory, theory and practice are the same. In practice, they are not."
    Albert Einstein
View as RSS news feed in XML