title: Regex to match a price string
body: <p>I am new in PHP. I was trying to check if one of the form inputs (contained in <code>$price</code> for this example) is a decimal as follows:</p>
  
  <pre><code>if(!preg_match("\\d+(.\\d{1,2})?", $price))
      //do something
  </code></pre>
  
  <p>In Java, it would have been</p>
  
  <pre><code>price.matches("\\d+(.\\d{1,2})?")
  </code></pre>
  
  <p>But the same regex is not working in PHP. Does <code>preg_match</code> match substrings as well? </p>
  
  <p>I expect the following inputs to be true:</p>
  
  <pre><code>300
  300.5
  300.56
  </code></pre>
  
  <p>All other formats should be false. I cannot figure out how to do that in PHP.</p>