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
Post a Comment