title: RegEx for decimal number with precision of two
body: <p>I need a regular expression that accepts only decimal numbers, to two decimals.
  I have already tried <code>^\d{1,}(\.\d{2})?$'</code> but i do not want it to use the optional group, because that will allow <code>1</code> to pass. If take out the optional group, it will not allow <code>1.00</code> to pass.</p>
  
  <p>my code:</p>
  
  <pre><code>[double]$bookPrice = read-host "Enter book price "
  if($bookPrice -notmatch '^\d{1,}(\.\d{2})?$'){
          [console]::beep(500,300)
          Write-Host "invalid"
  }
  </code></pre>
  
  <p>Valid:</p>
  
  <pre><code>1.00
  1.12
  </code></pre>
  
  <p>Invalid:</p>
  
  <pre><code>1
  1.000000
  </code></pre>
  
  <p>The only thing that I think will solve the problem is changing the variable <code>$bookPrice</code>to string, but I do not want to waste a line converting it back to double.</p>