Notice that there is whitespace after the book name and before the chapter number, right before the colon that separates chapter and verse numbers.Originally Posted by goldfish
Notice that there is whitespace after the book name and before the chapter number, right before the colon that separates chapter and verse numbers.Originally Posted by goldfish
Look up a C++ Reference and learn How To Ask Questions The Smart WayOriginally Posted by Bjarne Stroustrup (2000-10-14)
Yeah, I noticed that this morning. I haven't come up with a really good answer.
If the book name was quoted or something -- "I Kings" -- it would be easy to parse.
I think you will need a custom algorithm. You will have to scan the line for the location of the book name. Look for the first digit in the line; everything before that can be considered part of the book name. If you do this part by reading, as opposed to creating a substring, it may be easier since you have a stringstream.
I don't think it is that hard. It should be possible to match with regex, e.g., "^(\.+?) (\d+):(\d+): " (PCRE, or something like that). If there is no match, then you should be dealing with a verse continuation. Otherwise, you search the list of books for the first match group to confirm, then convert the next two match groups to chapter and verse numbers, then go for the verse itself.
Look up a C++ Reference and learn How To Ask Questions The Smart WayOriginally Posted by Bjarne Stroustrup (2000-10-14)