Hey, i was wondering if someone could help me figure out what i am doing wrong with this c# regex code. It highlights what i want but it doesnt highlight the exact match and i keep getting errors.
For example. “This is the queen bee”. be would be highlighted in the “bee”. Any help would be greatly appreciated.
string searchTerms = new { “be”, “being”, “been”, “am”, “is”};
if (richTextBox1.Text != string.Empty)
{
string text = richTextBox1.Text;
richTextBox1.Text = "";
richTextBox1.Text = text;
foreach (Match m in new Regex(@"\b("string.Join("|", searchTerms.Select(t => t.Replace("|", "\\|")))).Matches(richTextBox1.Text)
)
{
richTextBox1.Select(m.Index, m.Length);
richTextBox1.SelectionColor = Color.Red;
thank you