有没有办法将此代码转换为单行preg_replace()以避免重复代码?提前谢谢。
$string = preg_replace('/[^ \w]+\'/', ' ', $string); // Removes special chars except spaces and single quote.
$string = preg_replace('/\'/', '!', $string); //Replace single quotes to exclamation
$string = preg_replace('/-/', '^', $string);
$string = str_replace(' ', '-', $string); //Change spaces to -
$string = preg_replace('/\s\s+/', '!-', $string)