Something like the below will loop for each keyword until there are no more matches left for that keyword - but it wont be perfect because it will skip over other keywords while it's looking e.g "if you had this and that or the other and something" you'd strip out all the Ands before stripping out the Or What you need to do is Repeat Find the first occurrence of ANY of the keywords in your sentence. Split the sentence Until no occurrences found Using the IndexOf method you can loop through your keywords, finding the lowest, non zero value of IndexOf and storing that word. When the loop finishes , split the sentence using that word.
bool finished = false;
while (not finished)
if ((remSentence.Contains(keywords[i])))// || (remSentence.IndexOf(keywords[i]) > 0))
{
richTextBox2.Text += remSentence.Substring(0, remSentence.IndexOf(keywords[i])) + '\n' + keywords[i] + '\n';
remSentence = remSentence.Substring(remSentence.IndexOf(keywords[i]) + keywords[i].Length);
}
else
{
finished = true;
}