Text question
in
Programming Questions
•
1 year ago
I am splitting a text file into sentences, which I then want to be able to display individually.
I'm splitting into sentences this way:
String[] paragraphs;
void setup(){
paragraphs = loadStrings("article.txt");
for (int j=0; j<paragraphs.length; j++) {
String sentences[] = split(paragraphs[j], '.');
println(sentences[j]);
}
}
This removes the period and also includes the space between sentences at the beginning of each sentence,
so instead of
"The dog ran."
I have
" The dog ran"
I know how to add the period back in, but is there an easy way to remove that space at the beginning, or keep it from being included in the first place?
1