Try this:
String text = "line 1
line 3
line 5";
String adjusted = text.replaceAll("(?m)^[ ]*
?
", "");
// ...
Note that the regex [ |]
matches a space, a tab or a pipe char!
EDIT
B.t.w., the regex (?m)^s+$
would also do the trick.
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…