Syntax Highlighting Code
private void richTextBox1_TextChanged(object sender, EventArgs e)
{
string tokens = "(auto|double|int|struct|break|else|long|switch|case|enum|register|typedef|char|extern|return|union|const|float|short|unsigned|continue|for|signed|void|default|goto|sizeof|volatile|do|double|if|static|while)";
Regex rex = new Regex(tokens);
MatchCollection mc = rex.Matches(richTextBox1.Text);
int StartCursorPosition = richTextBox1.SelectionStart;
foreach (Match m in mc)
{
int startIndex = m.Index;
int StopIndex = m.Length;
richTextBox1.Select(startIndex, StopIndex);
richTextBox1.SelectionColor = Color.Red;
richTextBox1.SelectionStart = StartCursorPosition;
richTextBox1.SelectionColor = Color.Blue;
}
Prroblem is while do and double has same name starting so it was not working properl so any one provide a good code for me..