简体   繁体   中英

regex pattern replace from coma to dollar($) in php

i have a problem with regex, i did effort with this code "

$pattern ='(\"[,]\")';
$replacement = '$';
$string='array("FORM", "481072307", "481072307"),array("pattern_x", "3,1,1990","02,121"),array("pattern_y", "f,g,j","1,36"),array("STARTDATE", "08/07/2014","07/11/2014")';
$output = preg_replace($pattern,$replacement,$string);

this is the output :

array("FORM", "481072307", "481072307"),array("pattern_x", "3,1,1990$02,121"),array("pattern_y","f,g,j$1,36"),array("STARTDATE", 08/07/2014","07/11/2014")

but it was not i expected, but this :

array("FORM", "481072307", "481072307"),array("pattern_x", "3,1,1990'$'02,121"),array("pattern_y","f,g,j'$'1,36"),array("STARTDATE", /07/2014","07/11/2014");

hope anybody help true regex with my case. Thanks.

试试这个: $replacement = "'$'";

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM