I need to replace the duplicate characters in a string. I tried using
outputString = str.replaceAll(\"(.)(?=.*\\\\1)\", \"\");
This replac
It seems like your code is leaving the last character, so how about this?
outputString = new StringBuilder(str).reverse().toString();
// outputString is now hiah
outputString = outputString.replaceAll("(.)(?=.*\\1)", "");
// outputString is now iah
outputString = new StringBuilder(outputString).reverse().toString();
// outputString is now hai