regex - PHP replace all dots to comma -
this question has answer here:
- replace comma(,) dot(.) regex php 5 answers
i have string
10.2, 200.3, 33.00
and want replaced
10,2, 200,3, 33,00
i tried
preg_replace("/[.]$/","/\d[,]$/",$input);
but not replacing!
i can't use str_replace
because it's task in university
preg_replace('/\./', ',', $input);
this replace '.' dots ','.
preg_replace('/(\d+).(\d+)/', '$1,$2', $input);
this more specific need. $1 replaces first digit in parenthesis; $2 second.
-buy me beer nw ;)
Comments
Post a Comment