compress the same characters in string