如果有多於三個的字符,我想替換每個WORD中的所有連續字符(三種是德語中最可能的,兩種是英語,因此我知道輸出示例在語法上是錯誤的) 。PHP替換句子中連續出現的字符
示例輸入:
Hellooooo Louis, whaaaaaat's up pal?
預期輸出:
Hellooo Louis, whaaat's up pal?
我試圖改變:
preg_replace('/(\w)\1+/', '$1', $word);
到
preg_replace('/(\w)\3+/', '$1', $word);
但是,它不輸出任何內容。
http://en.wikipedia.org/wiki/List_of_words_in_English_with_tripled_letters – foxbeefly
@foxbeefly:哈,不知道他們有3個英文也是如此:-) –