Remove multiple duplicate characters from string
php, string
Solution
You can do this using regular expressions and `preg_replace()`:
$new_str = preg_replace('/(.)\1{3,}/', '', $str);
Problem
I have strings like this one: ``` $str = 'This -----is a bbbb test'; ``` How can I remove all duplicate characters if it occurs more than 3 times? So, for example, the string above must look as follows: ``` 'This is a test'; ```