Reputation: 123
E.g.
String s = "You should always brush your teeth before every meal in the day.";
but I want do split part of it into a new sentence like so:
String s = "You should always brush your teeth/nbefore every meal in the day.";
so the result is this:
String s = "You should always brush your teeth";
String s2 = "before every meal in the day.";
Basically, I want it to search for the "/n" and then separate the next sentence from the present one.
Upvotes: 2
Views: 119
Reputation: 9380
String[] str = s.split("/n");
if(str.length == 2) {
s = str[0];
s2 = str[1];
}
Upvotes: 2
Reputation: 14169
You can split your string into an array of strings doing
String[] chunks = s.split("\\n");
Upvotes: 0