fork download
  1. /* package whatever; // don't place package name! */
  2.  
  3. import java.util.*;
  4. import java.lang.*;
  5. import java.io.*;
  6.  
  7. /* Name of the class has to be "Main" only if the class is public. */
  8. class Ideone
  9. {
  10. public static void main(String[] args) throws Exception {
  11. String trimm = "ABC 123|1|2 ABC '123|1|2|\"Jan 30 2018 2:34:13:000AM\"|dd1|1|\"Jan 30 2018 2:56:08:000AM\"|EST' ABC 20180821\n" +
  12. "ABC 123|1|2 ABC '123|1|2|\"Jan 30 2018 2:34:13:000AM\"|dd1|1|\"Jan 30 2018 2:56:08:000AM\"|EST' ABC 20180821\r\n";
  13.  
  14. System.out.println("---------------------------------------------------Before replace Start of the input---------------------------------------------------");
  15. System.out.println(trimm);
  16. System.out.println("---------------------------------------------------Before replace End of the input---------------------------------------------------");
  17.  
  18. System.out.println("---------------------------------------------------After replace Start of the input---------------------------------------------------");
  19. trimm = trimm.replaceFirst("[\n\r]+$", "");
  20. System.out.println(trimm);
  21. System.out.println("---------------------------------------------------After replace End of the input---------------------------------------------------");
  22.  
  23. }
  24. }
Success #stdin #stdout 0.09s 27932KB
stdin
Standard input is empty
stdout
---------------------------------------------------Before replace Start of the input---------------------------------------------------
ABC 123|1|2 ABC '123|1|2|"Jan 30 2018  2:34:13:000AM"|dd1|1|"Jan 30 2018  2:56:08:000AM"|EST' ABC 20180821
ABC 123|1|2 ABC '123|1|2|"Jan 30 2018  2:34:13:000AM"|dd1|1|"Jan 30 2018  2:56:08:000AM"|EST' ABC 20180821

---------------------------------------------------Before replace End of the input---------------------------------------------------
---------------------------------------------------After replace Start of the input---------------------------------------------------
ABC 123|1|2 ABC '123|1|2|"Jan 30 2018  2:34:13:000AM"|dd1|1|"Jan 30 2018  2:56:08:000AM"|EST' ABC 20180821
ABC 123|1|2 ABC '123|1|2|"Jan 30 2018  2:34:13:000AM"|dd1|1|"Jan 30 2018  2:56:08:000AM"|EST' ABC 20180821
---------------------------------------------------After replace End of the input---------------------------------------------------