D
D
Diversia2018-06-07 13:15:10
PHP
Diversia, 2018-06-07 13:15:10

Why doesn't preg_replace react to Cyrillic?

Why doesn't preg_replace react to Cyrillic?

$str = 'Сссссууууууупппппппеееееерррррр!!!!!! SuuPpEEr!';
echo preg_replace('~(.)\1+~i', '\\1', $str);

// вывод:
// Сссссууууууупппппппеееееерррррр! SuPEr!

Answer the question

In order to leave comments, you need to log in

1 answer(s)
D
Dmitry Kim, 2018-06-07
@Diversia

echo preg_replace('~(.)\1+~ui', '\\1', $str);
u - UNICODE

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question