$re = '/.+&(q=[^&]+).+/m';
$str = 'https://www.google.com/search?source=hp&ei=Ne4pXpSIHIW_9QOD-rmADw&q=laravel+crud+generator&oq=laravel+crud+generator&gs_l=psy-ab.3..0l8.1294.6845..7289...1.0..0.307.3888.0j20j2j1......0....1..gws-wiz.....6..0i131j0i362i308i154i357.PwlZ_932pXo&ved=0ahUKEwjU9pz4tJrnAhWFX30KHQN9DvAQ4dUDCAU&uact=5';
$subst = "https://www.google.com/search?$1";
$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