title: How to detect a floating point number using a regular expression
body: <p>What is a good regular expression for handling a floating point number (i.e. like Java's Float)</p>
  
  <p>The answer must match against the following targets:</p>
  
  <pre><code> 1) 1.  
   2) .2   
   3) 3.14  
   4) 5e6  
   5) 5e-6  
   6) 5E+6  
   7) 7.e8  
   8) 9.0E-10  
   9) .11e12  
  </code></pre>
  
  <p>In summary, it should </p>
  
  <ul>
  <li>ignore preceding signs  </li>
  <li>require the first character to the left of the decimal point to be non-zero</li>
  <li>allow 0 or more digits on either side of the decimal point</li>
  <li>permit a number without a decimal point</li>
  <li>allow scientific notation</li>
  <li>allow capital or lowercase 'e'</li>
  <li>allow positive or negative exponents</li>
  </ul>
  
  <p>For those who are wondering, yes this is a homework problem.  We received this as an assignment in my graduate CS class on compilers. I've already turned in my answer for the class and will post it as an answer to this question.</p>
  
  <p>[Epilogue]
  My solution didn't get full credit because it didn't handle more than 1 digit to the left of the decimal.  The assignment did mention handling Java floats even though none of the examples had more than 1 digit to the left of the decimal.  I'll post the accepted answer in it's own post.</p>