I use a C# Winforms RichTextBox to load and show some logfiles.
Those logfiles uses ANSI escape chars to colorize the logfiles.
Found some examples to find and highlight a search string but I want to search for start and end strings, get those selections and colorize the content between.
Example:
previous text ESC[36m SOME LOG CONTENT ESC[0m Some more text
ESC[36m
ESC[0m
TextRange
TextRange
Try using regular expressions. This should do it.
rtb.Text = "previous text ESC[36m SOME LOG CONTENT ESC[0m Some more text";
Regex regex = new Regex(@"ESC\[36m(.*?)ESC\[0m", RegexOptions.Multiline);
foreach (Match m in regex.Matches(rtb.Text))
{
rtb.Select(m.Index + 7, m.Value.Length - 13);
rtb.SelectionColor = Color.Aqua;
}