$str = "The quick brown fox jumped over the lazy dog.";
$str = preg_replace('/\s/','-',$str);
echo $str;

更详细的请看原著
摘抄自http://www.5idev.com/p-php_preg_replace.shtml

相关文章: