如何使用正则表达式?

i want to split some caracters into a string . The string contains this define("coco","coco"); i want with regular expressions split the 'define' , the '(' , the ')' and replace the ',' by '=' . How can i do?

Well, if you want to delete ("split") those values this is quite simple, you don't need Regex.

<?php

$str = 'define("coco","coco")';

echo str_replace('define(', '', str_replace(",", "=", str_replace(")", "", $str)));

Another way is by using preg_replace, but we have already an answer for it.

You can go with :

$string = 'define("coco","coco")';

$newString = preg_replace('/define\(("[^"]+"),("[^"]+")\)\;/isU', "$1=$2", $string);