$re = '/(.*)\/.*/m';
$str = '/public_html/reviews/index.php';
$subst = '$1';
$result = preg_replace($re, $subst, $str);
echo "The result of the substitution is ".$result;
$re = '/([^\(]+)\(([^(]+)\(([^)]+).*/m';
$str = 'arr(s(ptr:4_size:4))';
$subst = '[\'$1\', \'$2($3)\']\\r\\n[\'$2\', \'$3\']';
$result = preg_replace($re, $subst, $str);
echo "The result of the substitution is ".$result;
const regex = /(.*?,.*?,.*?),.*/gm;
const str = `000000, Регион, Населенный пункт, Название улицы, 25`;
const subst = `$1`;
// The substituted value will be contained in the result variable
const result = str.replace(regex, subst);
console.log('Substitution result: ', result);