title: RegEx to keep only the last dot from a string
body: <p>How can I keep only last dot and remove every other dots from a string using preg_replace().</p>
  
  <p>Example string:</p>
  
  <pre>1.000.000.00</pre>
  
  <p>Expected result:</p>
  
  <pre>1000000.00</pre>
  
  <p>My code: </p>
  
  <pre><code>$pattern = '/[^0-9\.]/';
  $amount = '1.000.000.00';
  echo preg_replace($pattern, "", $amount);
  </code></pre>
  
  <p>How do I solve this problem?</p>
  
  <p><strong>Edit:</strong>
  Besides removing last dot in a number and removing any char that is not a digit or dot character from the string, I also need the dot removed, if it is present at the end of number like this,</p>
  
  <pre><code>1.000.000.00. after replacement should become 1.000.000.00
  </code></pre>
  
  <p>What should I do in addition to my current regex <code>[^0-9\.]</code> to achieve this?</p>