Click here to Skip to main content
12,249,821 members (50,829 online)
Rate this:
 
Please Sign up or sign in to vote.
See more: ASP.NET
Please provide me the regular expression for the numbers below 2100
Posted 28-Nov-12 20:35pm

1 solution

Rate this: bad
 
good
Please Sign up or sign in to vote.

Solution 1

While you could do a regex for "all numbers below nnnn" it would be extremely long and difficult to maintain. Regular expressions are text matching processors, not numeric comparators, and there are better ways to do this kind of validation. Parse the text to an integer, and (if it works) check it's numeric value. It will be quicker to write, quicker to execute, a lot clearer to read, and much, much easier to maintain.


Regexes are very powerful tools, but like any tool, they should be used for the correct job. Would you use a soldering iron to hang a picture?
  Permalink  

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
Top Experts
Last 24hrsThis month


Advertise | Privacy | Mobile
Web02 | 2.8.160426.1 | Last Updated 29 Nov 2012
Copyright © CodeProject, 1999-2016
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100