java - Inserting Newline character before every number occurring in a string? -
I have a string of format like something
string VIA = "1.NEW DELHI 2. Lucknow 3. Agra ";
Before every digit happens, I want to insert a new row, it succeeds in the dot so that it is like the last string
String VIA = "1.NEW DELHI" + "\ n" + "2. Lucknow" + "\ n" + "3" Agra ";
How can I do this? StringBiller and String have been read, but now I am confused.
Something like this:
stringbuilder builder = new stringbiller (); String [] partition = VIA.split ("\ d + \."); (String split: splits) {builder.append (split) .append ("\ n");} string output = builder.tstring ( ). Trim ();
Comments
Post a Comment