Click here to Skip to main content
15,885,435 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Please provide me the regular expression for the numbers below 2100
Posted

1 solution

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?
 
Share this answer
 

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



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900