title: Javascript Regex: validating a double/float
body: <p>Here's the pattern I'm working on:</p>
  
  <pre><code>var re = /(\d{1,2}\.(?=\d{1,2}))/;
  </code></pre>
  
  <p>What I would like for this to return is a one or two digit number (which will never be greater than 24, since it is for a time mgmt app), which may or may not be followed by a decimal point with either one or two trailing digits, but not more than two.</p>
  
  <p>I'm not sure about the parenthetical substring match mixed with the lookahead. I just guessed and nested them. Ultimately, if my syntax is okay, I think the only thing I am missing is how to suggest that the pattern may or may not have leading digits, and may or may not contain a decimal with trialing digits.</p>
  
  <p>Let me know if you need more info.</p>
  
  <p>Update, Examples:</p>
  
  <p>We are only dealing with time, and no more time than can occur in a single day. 24 would be the highest input.</p>
  
  <p>Valid: </p>
  
  <pre><code>23.75
  1.4 
  1
  0.5 
  0
  .2
  </code></pre>
  
  <p>Invalid:</p>
  
  <pre><code>1.897
  %#$#@$#
  Words
  other characters
  </code></pre>
  
  <p>Newest Update:</p>
  
  <p>Since this is a decimal, 23.75 works. We are not counting minutes, but rather fractions of hours.</p>
  
  <p>Also, for the record, I tried validating using methods and conditionals, and it was letting letters pass through after the decimals. I have made the decision to go with regex.</p>