public class ReplaceQuestionMarks {
public static void main(String[] args) {
String str = "Hello??? How are you?? What is your Wi-Fi password????";
// Replace multiple '?' with a single '?'
String result = str.replaceAll("\\?+", "?");
System.out.println(result);
}
}
/*
run:
Hello? How are you? What is your Wi-Fi password?
*/