php - replace trailing zeros regex with dot(.) and comma(,) including delimiter , -


i use regular expression remove trailing zeros numbers dot(.) delimiter:

(?:(\.\d*[1-9])|\.)0*$  

and i'm replacing $1.

example:

  • 9.50
  • 2.00
  • 3.06
  • 3.000

it give me:

  • 9.5
  • 2
  • 3.06
  • 3

but doesn't seem work same way comma(,). tried no luck:

(?:(\,\d*[1-9])|\,)0*$ 

i'm new php , first question here. thank in advance.

if these separate strings, numbers only, use: [.,]?0*$ , replace empty string.


Comments

Popular posts from this blog

delphi - How to convert bitmaps to video? -

jasper reports - Fixed header in Excel using JasperReports -

python - ('The SQL contains 0 parameter markers, but 50 parameters were supplied', 'HY000') or TypeError: 'tuple' object is not callable -