Why regular expressions are considered a universal panacea for all life's problems (simply because the low feedback in preg_match discovered a cure for cancer). here's a solution without resorting to regex:
$str = "Topic: Some stuff, Maybe some more, it my stuff?"; $str = implode('-',str_word_count(strtolower($str),2)); echo $str;
Without moving the entire UTF-8 route:
$str = "Topic: Some stuff, Maybe some more, it my Iñtërnâtiônàlizætiøn stuff?"; $str = implode('-',str_word_count(strtolower(str_replace("'","",$str)),2,'Þßàáâãäåæçèéêëìíîïðñòóôõöøùúûüýþÿ')); echo $str;
gives
topic-some-material, perhaps a little more-his-mine-iñtërnâtiônàlizætiøn-material
source share