希望这是一个简单的过程。我有一个包含 CSV 文件输出的行的数组。我需要做的只是删除出现在双引号之间的任何逗号。
我在正则表达式中磕磕绊绊,遇到了麻烦。这是我看起来很悲伤的代码:
<?php
$csv_input = '"herp","derp","hey, get rid of these commas, man",1234';
$pattern = '(?<=\")/\,/(?=\")'; //this doesn't work
$revised_input = preg_replace ( $pattern , '' , $csv_input);
echo $revised_input;
//would like revised input to echo: "herp","derp,"hey get rid of these commas man",1234
?>
非常感谢大家。