Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>This reminds me of <a href="http://weblogs.asp.net/alex_papadimoulis/archive/2005/05/25/408925.aspx" rel="nofollow noreferrer">an old blog Entry</a> By Alex Papadimoulis (of <a href="http://thedailywtf.com/" rel="nofollow noreferrer">The Daily WTF</a> fame) where he tells the following story:</p> <blockquote> <p>"A client has asked me to build and install a custom shelving system. I'm at the point where I need to nail it, but I'm not sure what to use to pound the nails in. Should I use an old shoe or a glass bottle?"</p> <p>How would you answer the question?</p> <ol> <li><p>It depends. If you are looking to pound a small (20lb) nail in something like drywall, you'll find it much easier to use the bottle, especially if the shoe is dirty. However, if you are trying to drive a heavy nail into some wood, go with the shoe: the bottle with shatter in your hand.</p></li> <li><p>There is something fundamentally wrong with the way you are building; you need to use real tools. Yes, it may involve a trip to the toolbox (or even to the hardware store), but doing it the right way is going to save a lot of time, money, and aggravation through the lifecycle of your product. You need to stop building things for money until you understand the basics of construction.</p></li> </ol> </blockquote> <p>This is such a question where most people sees it as a challenge to come up with the correct regular expression to solve the problem, but it would be much better to just say that using regular expressions are using the wrong tool for the job.</p> <p>The problem when trying to use regex to validate numeric ranges is that it is hard to change if the requirements for the allowed range is changes. Today the requirement may be to validate numbers between 0 and 100 and it is possible to write a regex for that which doesn't make your eyes bleed. But next week the requirment maybe changes so values between 0 and 315 are allowed. Good luck altering your regex. </p> <p>The solution given by Greg Hewgill is probably better - even though it would validate "99fxx" as "99". But given the circumstances that might actually be ok.</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload