I have a piece of text which is in the following format:
"1. Question blah blah blah. goes on blah blah
Answer: Answer blah, blah goes on like
this blah blah.
2. One more question. blah blah goes
on like this again.
Answer: Again and again, over and over."
Now taking a piece of text, I have to break it down to pairs of
question and answer sets so that they can be saved in to question
model - which has a question and answer attribute. A single piece of
text saved in a Post model needs to be parsed into a number of
The problem is that the text is very idiosyncratic, with numerous line
breaks and carriage returns inside each question and answer but the
numbering and the "Answer:" segments are present accurately. From what
I read through various sources, this can be accomplished through
regular expressions but I am not able to figure out how to go about
this. Could someone explain how this can be accomplished for this