title: Regular expression to find decimal numbers in a string
body: <p>I am trying to search a string that has embedded decimal numbers. The number uses comma for (hundred / thousand separator) and dot for decimal separator.</p>
  
  <p><strong>Example of invalid decimal numbers:</strong></p>
  
  <ul>
  <li>.33, .333 (Number must be preceded with at least 1 digit albeit zero)</li>
  <li>1,22,33.33, 1,22.333 (last segment in comma separated digits must have 3 digits)</li>
  <li>.3, .3333 (Decimal number must have 2 or 3 digits after decimal)</li>
  <li>,0.33 (Decimal number must not start with comma)</li>
  </ul>
  
  <p><strong>Example of valid decimal numbers:</strong></p>
  
  <ul>
  <li>0.33 &amp; 10.333</li>
  <li>1,22,333.33 &amp; 1,222.333</li>
  </ul>
  
  <p><strong>Special case:</strong> If the string is like "You a/c bal.33.33". The result should be 33.33</p>
  
  <hr>
  
  <p>I have tried following regex:</p>
  
  <pre><code> (((\\d+\\,)+\\d{3})|([^,]\\d+))\\.\\d{2,3}(?!\\.\\d)
  </code></pre>
  
  <p>It works for all cases but fails when number has leading comma. </p>