Следующая функция разделяет некоторые слова на массив, корректирует пробелы и делает что-то еще, что мне нужно. Мне также нужно убрать тире, так как я тоже пишу их как слова. Но эта функция не удаляет тире. Что случилось?
function stripwords($string)
{
// build pattern once
static $pattern = null;
if ($pattern === null) {
// pull words to remove from somewhere
$words = array('alpha', 'beta', '-');
// escape special characters
foreach ($words as &$word) {
$word = preg_quote($word, '#');
}
// combine to regex
$pattern = '#\b(' . join('|', $words) . ')\b\s*#iS';
}
$print = preg_replace($pattern, '', $string);
list($firstpart)=explode('+', $print);
return $firstpart;
}
$pattern
? - person Ignacio Vazquez-Abrams   schedule 05.07.2011