SELECT regexp_replace(' aaa bbb 888 bbb ccc ddd fff YESS', '(.)\1+', '\1', 'g');
Return: a b 8 b c d f YES
Expect: a b 8 b c d f YESS
The pattern : if there are 3 repeated characters (before and after both have more than 0 white spaces), only extract one character.
Related Question: Remove Consecutive Repeated Characters with PostgreSQL regexp_replace function