title: regex replace for decimals
body: <p>I'm trying build a regex that will replace any characters not of the format:</p>
  
  <p>any number of digits, then optional (single decimal point, any number of digits)</p>
  
  <pre><code>i.e.
  123            // 123
  123.123        // 123.123
  123.123.123a   // 123.123123
  123a.123       // 123.123
  </code></pre>
  
  <p>I am using ereg_replace in php and the closest to a working regex i have managed is</p>
  
  <pre><code>ereg_replace("[^.0-9]+", "", $data);
  </code></pre>
  
  <p>which is almost what i need (apart from it will allow any number of decimal points)</p>
  
  <pre><code>i.e.
  123.123.123a    // 123.123.123
  </code></pre>
  
  <p>my next attempt was</p>
  
  <pre><code>ereg_replace("[^0-9]+([^.]?[^0-9]+)?", "", $data);
  
  which was meant to translate as
  [^0-9]+        // any number of digits, followed by
  (              // start of optional segment
    [^.]?        // decimal point (0 or 1 times) followed by
    [^0-9]+      // any number of digits
  )              // end of optional segment
  ?              // optional segment to occur 0 or 1 times
  </code></pre>
  
  <p>but this just seems to allow any number of digits and nothing else.</p>
  
  <p>Please help</p>
  
  <p>Thanks</p>