$re = '/(.*?\'hello\'.*?),\'hello\',(.*)/';
$str = '\'one\',2,\'three\',\'hello\',\'xyz\',5,\'hello\',\'mnr\',\'hello\',\'axi\'
\'onae\',2,\'tree\',\'hello\',\'xyz\',6,\'hello\',\'mnr\',\'hello\',\'asd\'
\'onee\',2,\'xdsa\',\'hello\',\'xyz\',5,\'hello\',\'mnr\',\'hello\',\'aew\'
\'owne\',2,\'thr\',\'hello\',\'xyz\',3,\'hello\',\'mnr\',\'hello\',\'az\'
\'ocne\',2,\'tee\',\'hello\',\'xyz\',5,\'hello\',\'mnr\',\'hello\',\'zse\'
\'owne\',2,\'tre\',\'hello\',\'xyz\',2,\'hello\',\'mnr\',\'hello\',\'aai\'';
$subst = "$1,0,$2";
$result = preg_replace($re, $subst, $str);
echo "The result of the substitution is ".$result;
Please keep in mind that these code samples are automatically generated and are not guaranteed to work. If you find any syntax errors, feel free to submit a bug report. For a full regex reference for PHP, please visit: http://php.net/manual/en/ref.pcre.php