Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/243.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/regex/16.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
PHP preg_替换字符串文本_Php_Regex_String_Replace_Preg Replace - Fatal编程技术网

PHP preg_替换字符串文本

PHP preg_替换字符串文本,php,regex,string,replace,preg-replace,Php,Regex,String,Replace,Preg Replace,我正在尝试替换以下每一个实例: {{anythinghere::anythingthere}} 一串 任何帮助都将不胜感激,因为您没有指定要用什么替换它: preg_replace("/{{([^:}]+)::([^:}]+)}}/", "First_param: $1, Second_param: $2", $target_string); 这将返回第一个参数:anythinghere,第二个参数:anythinghere,因为您没有指定要用什么替换它: preg_replace("/{

我正在尝试替换以下每一个实例:

{{anythinghere::anythingthere}} 
一串


任何帮助都将不胜感激,因为您没有指定要用什么替换它:

preg_replace("/{{([^:}]+)::([^:}]+)}}/", "First_param: $1, Second_param: $2", $target_string);

这将返回
第一个参数:anythinghere,第二个参数:anythinghere

,因为您没有指定要用什么替换它:

preg_replace("/{{([^:}]+)::([^:}]+)}}/", "First_param: $1, Second_param: $2", $target_string);

这将返回
First\u param:anythinghere,Second\u param:anythinghere

,您想用什么替换它们?假设其余的是文字字符,请定义任何内容。同时回答Spudley的问题。用什么替换什么?给我一个字符串示例和所需的结果,然后用什么替换它们?假设其余的是文字字符,请定义任何内容。同时回答Spudley的问题。用什么替换什么?给我一个字符串示例和所需的结果