How to highlight a word using REGEX

0

I need to color in the RichTextBox a text before a string For example:

"Highlight: normal highlight"

    
asked by anonymous 10.01.2018 / 11:43

1 answer

5

See if this can help you

private void ColourRrbText(RichTextBox rtb)
    {
        Regex regExp = new Regex("^([^:]*)");

        foreach (Match match in regExp.Matches(rtb.Text))
        {
            rtb.Select(match.Index, match.Length);
            rtb.SelectionColor = Color.Blue;
        }
    }
    
10.01.2018 / 12:05