title: Regular Expression to get comments in VB.Net source code
body: <p>I have a syntax highlighting function in vb.net. I use regular expressions to match "!IF" for instance and then color it blue. This works perfect until I tried to figure out how to do comments. </p>
  
  <p>The language I'm writing this for a comment can either be if the line starts with a single quote '  OR if anywhere in the line there is two single quotes</p>
  
  <pre><code>'this line is a comment
  !if StackOverflow = "AWESOME" ''this is also a comment
  </code></pre>
  
  <p>Now i know how to see if it starts with a single line ^' but i need to to return the string all the way to the end of the line so i can color the entire comment green and not just the single quotes.</p>
  
  <p>You shouldn't need the code but here is a snippet just in case it helps. </p>
  
  <pre><code>    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
  </code></pre>