fork download
  1. class Test{
  2. public static void main(String[] args){
  3. String str = "They are working in London..... he is a Java developer !!!!! they are playing-----She is working_______";
  4. String newStr = str.replaceAll("([|\\-|\\.|\\!|\\_])\\1+", "$1");
  5. System.out.println(newStr);
  6. }
  7.  
  8. }
Success #stdin #stdout 0.08s 380224KB
stdin
Standard input is empty
stdout
They are working in London. he is a Java developer ! they are playing-She is working_