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

jasper reports - Fixed header in Excel using JasperReports -

media player - Android: mediaplayer went away with unhandled events -

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