I don't have the text file with me (at work) right now. But, here's what it look likes.
Title of Book 1 (Can be ignored)
1:1 When I was a wee little lad, I sailed the ocean blue with my father. 1:2 Along the way, we were attacked by a band of thieving pirates and mermaids. 1:3 Fortunately, we were able to bribe them off with spagehttios and cheesy bread.
2:1 After 42 days on the sea, we ran into Davy Jones. 2:2 He was a kind man, though a bit thin, pasty and pale. 2:3 He offered to show us his locker, but we were short on time and politely told him we'd have to visit "some other day". 2:4 He replied with a strange smile, "Oh, yes you will. Indeed".
3:1 And everyone lived happily ever after.
Title of Book 2 (again, ignore)
1:1 Bobo is a curious man. 1:2 He's been master of ceremonies at the circus for 15 years now. 1:3 And for some strange reason, he loves to punch his clown. 1:4 All day long, he punches his clown. 1:5 Nobody knows why. 2:1 One day, while Bobo was punching his clown, his mother came to the circus. 2:2 She was horrified at what she saw. 2:3 "Bobo, why are you punching your clown!?", she exclaimed. "You know that's not how I raised you". 2:4 Embarassed, Bobo quickly put his clown away and tried to explain things away.
First let me say, the text above is just made up off the top of my head. As if you couldn't tell....
OK, so each book has a title line and there are hundreds of books in this file. Each passage in a book is marked as CHAPTER😛ASSAGE. Same kind of format used in a Bible. The Chapters can range from 1-120, and so can the Passages.
What I want to do is this:
Move through this text file searching for #:#, or [1-120]:[1-120]. If this number is 1:1, then I know it is a new book. So, I have a variable that keeps track of what book I'm on. Whatever the case, I want to search for the next #:# and store the passage inbetween in a database, referencing the Book-Chapter-Passage. For example, the example information above would be stores as:
001001001 When I was a wee little lad, I sailed the ocean blue with my father.
001001002 Along the way, we were attacked by a band of thieving pirates and mermaids.
001001003 Fortunately, we were able to bribe them off with spagehttios and cheesy bread.
001002001 After 42 days on the sea, we ran into Davy Jones.
001002002 He was a kind man, though a bit thin, pasty and pale. 001002003 He offered to show us his locker, but we were short on time and politely told him we'd have to visit "some other day".
001002004 He replied with a strange smile, "Oh, yes you will. Indeed".
001003001 And everyone lived happily ever after.
002001001 Bobo is a curious man.
002001002 He's been master of ceremonies at the circus for 15 years now.
002001003 And for some strange reason, he loves to punch his clown.
002001004 All day long, he punches his clown.
002001005 Nobody knows why.
002002001 One day, while Bobo was punching his clown, his mother came to the circus.
002002002 She was horrified at what she saw.
002002003 "Bobo, why are you punching your clown!?", she exclaimed. "You know that's not how I raised you".
002002004 Embarassed, Bobo quickly put his clown away and tried to explain things away.
Above, the first three numbers are the Book, second three are Chapter, last three are Passage.
If I can go through the file and isolate the passages and extract the numbers I need, I can write a new file that adds the mysql code needed to insert the data in the table.