var regex = new Regex(textBox2.Text); List<string> matchingLines = new List<string>(); foreach (var richBoxItem in targetrichtextBox.ToString())// loop every item in your targetrichtextBox { string[] texts = targetListBox.Text.Split('?', '?', '\n'); foreach (var t in texts) { if (regex.IsMatch(t)) { //matchingLines.Add(targetTextBox2.Text.ToString()); matchingLines.Add(t.Trim()); //break; } } break; } targetTextBox2.Lines = matchingLines.ToArray();