In an interview, I was asked to remove all repeating adjacent characters in a string except one. For example, input : abbccasdjajksdhkjaaaaa output : abcasdjajksdhkja
In Java, the syntax will be
s.replaceAll("(.)\\1{1,}", "$1");
where s is the input string.