Backword Search Query

Let there be a sample text in a RichTextBox :

Q What is your name?
A My Name is William.
Q Do you know why we are here today?
A Yes I do.
Q Why is that?
A We are here because my dog bite Samuel Gordon.
Q How long ago did this happen?
A Approximately 14 months ago.
Q Where did this happen?
A In my backyard.
Q What is your address?
A 18 Court Place, Jordon’s house.
Q Was Mr. Gordon a guest of yours?
A No.
Q Why was he in your backyard?
A That is a mighty fine question.
Q Why do you think he was there?
A It appeared to me that he planned to rob me.
Q You personally?
A No, my home…

Now I have to perform a a backward search one for Question Set and another for Answer set.

The Question set starts with "Q " and the answer set starts with "A ".
I can easily search backward with

RichTextBox1.Text.lastIndexOf(“SearchText”,startIndex);…

But as I have to perform the same thing for two different set of lines in one RichTextBox, I have a little confusion.

The SearchQ button will perform backward search for the lines start with "Q " in the whole RichTextBox
And
The SearchA button will perform backward search for the lines start with "A " in the whole RichTextBox

Can anyone help me?

Thanks

You can use a StringReader. And then use the ReadLine() method to check for either starting with Q or A.

You could also split the string into a string, split it by the line ending, which could be <br /> or
, then loop through the array

Thanks.
This idea works.