To day I will show you How to Remove Empty Lines from string variable or string Variable containing XML Data .
This Code will Work on Both C# and Java Language.
In Code I use Reg-ex Expression To Detect or Find empty lines from String and Replace any other Character , join with Previous line or Else ..
Lets Start ;
the String Variable adjusted Contain String Data With on empty Lines.
I Also Tested It with JavaScript and IT Works Fine.
This Code will Work on Both C# and Java Language.
In Code I use Reg-ex Expression To Detect or Find empty lines from String and Replace any other Character , join with Previous line or Else ..
Lets Start ;
String text = "line 1\n\nline 3\n\n\nline 5"; String adjusted = text.replaceAll("(?m)^[ \t]*\r?\n", "");
the String Variable adjusted Contain String Data With on empty Lines.
I Also Tested It with JavaScript and IT Works Fine.
0 comments:
Post a Comment