从csv中删除逗号

时间:2017-11-02 13:34:12

标签: php regex csv preg-replace

我想从CSV中删除逗号(,)。 字符串如下。

10 ft.,11 ft. [Add $37.49],12 ft. [Add $74.98],13 ft. [Add $112.48],14 ft. [Add $149.97],15 ft. [Add $187.46],16 ft. [Add $224.95],17 ft. [Add $262.44],18 ft. [Add $299.94],19 ft. [Add $337.43],20 ft. [Add $374.92],25 ft. [Add $562.38],30 ft. [Add $749.84],35 ft. [Add $937.30],40 ft. [Add $1,124.76]

我想删除小数点。来自价格。

$1,124.76

所以最终必须是:

10 ft.,11 ft. [Add $37.49],12 ft. [Add $74.98],13 ft. [Add $112.48],14 ft. [Add $149.97],15 ft. [Add $187.46],16 ft. [Add $224.95],17 ft. [Add $262.44],18 ft. [Add $299.94],19 ft. [Add $337.43],20 ft. [Add $374.92],25 ft. [Add $562.38],30 ft. [Add $749.84],35 ft. [Add $937.30],40 ft. [Add $1124.76]

2 个答案:

答案 0 :(得分:1)

替换

OnGetCroppedImageCompleteListener

(\$\d+),(\d+)(?=\.\d+\])

Demo and some explanations

答案 1 :(得分:0)

这种接近可以删除你行上的所有逗号

<?php 
$string = "SET YOUR LINE";
echo preg_replace ( "/\$\d+,\d+/" , "" , $string );
?>