I'm reading in a text file and want to parse based on labels within the text file. At first I was trying to do this with patterns, but after spending some time reading the API documents, I'm not sure what I need.
I think I'm making this too complicated.
Example of .txt file:
Title: Grapes of Wrath
descriptions
Title: Almost Transparent Blue
more descriptions
I only want to capture text between Title: and \n
My code that doesn't work (nor should it) looks like this:
String[] lines = loadStrings("books.txt");
String bigstring = join(lines, " ");
String regex = "Title: ";
Pattern pattern = Pattern.compile(regex);
String[] items = pattern.split(bigstring);
for(int i=0; i < items.length; i++){
println(items[i] + "\n");}