I have syntax highlighting function in vb.net. I use regular expressions to match, for example, “! IF”, and then color it blue. This works perfectly until I tried to figure out how to make comments.
The language I write for comment can be either if the line starts with a single quote "OR, if there are two single quotes at any point in the line
'this line is a comment
!if StackOverflow = "AWESOME" ''this is also a comment
Now I know how to see if it starts with a single line ^, but I need to return the line to the end of the line so that I can color the entire green comment, not just single quotes.
You don't need the code, but here is a snippet just in case, if that helps.
For Each pass In frmColors.lbRegExps.Items
RegExp = System.Text.RegularExpressions.Regex.Matches(LCase(rtbMain.Text), LCase(pass))
For Each RegExpMatch In RegExp
rtbMain.Select(RegExpMatch.Index, RegExpMatch.Length)
rtbMain.SelectionColor = ColorTranslator.FromHtml(frmColors.lbHexColors.Items(PassNumber))
Next
PassNumber += 1
Next