简体   繁体   English

正则表达式模式从coma替换为php中的dollar($)

[英]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 = "'$'";

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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