fork(6) download
  1. import java.util.*;
  2. import java.lang.*;
  3. import java.io.*;
  4.  
  5. class Ideone
  6. {
  7. public static void main (String[] args) throws java.lang.Exception
  8. {
  9. String str = " text\n \n \n text";
  10. System.out.println(str.replaceAll("(?m)^[\\p{Zs}\t]+$", "").replace("\n", "\\n"));
  11. }
  12. }
Success #stdin #stdout 0.04s 711168KB
stdin
Standard input is empty
stdout
 text\n\n\n text