需要一些帮助升级一小块ereg_replace [重复]

This question already has an answer here:

I have this line of code I use for SEO purposes. The only thing is that it has an ereg_replace function in it. Now I get "ereg_replace() is deprecated" error.

Apparently it's not as simple as switching it to preg_replace and my RegEx-fu is not too strong. Any help would be highly appreciated.

Thanks.

  //make it lowercase, remove punctuation, remove multiple/leading/ending spaces
    $return = trim(ereg_replace(' +',' ',preg_replace('/[^a-zA-Z0-9\s]/','',strtolower($input))));
</div>

Here you go.

$return = trim(preg_replace('/[ ]+/i',' ',preg_replace('/[^a-zA-Z0-9\s]/','',strtolower($input))));

You just need to add delimeters

$return = trim(preg_replace('/ +/',' ',preg_replace('/[^a-zA-Z0-9\s]/','',strtolower($input))));

ereg_replace(' +' becomes preg_replace('/ +/'