title: JavaScript RegEx Syntax Highlighting
body: <p>I'm writing a jQuery plugin to highlight C++ code on my webpages. I'm not really too good with RegEx, so I can't figure out how to highlight keywords (like 'if', 'case', 'void', etc.) without highlighting parts of words (Like the 'int' in 'Paint'). I changed it a bit, but some things still don't get highlighted. This is what my RegEx looks like:</p>
  
  <pre><code>str = str.replace(new RegExp("([' ' || \t ||,|| \"\"])(" + ParserKeywordsArr[i] + ")", 'g'), "$1&lt;span style='color:" + ParserColorsArr[i] + ";'&gt;" + ParserKeywordsArr[i] + "&lt;/span&gt;");
  </code></pre>
  
  <p>This goes through every keyword I want highlighted, which is stored in an array, and theres another array with the colors (Ex. ParserKeywordsArr[0] is void, ParserColorsArr[0] is blue, so it would highlight in blue). However, when I put in something like this:</p>
  
  <pre><code>void CCodeEditorCtrl::OnPaint(WPARAM wParam, LPARAM lParam)
  {
      return;
  }
  </code></pre>
  
  <p>Return gets highlighted, but void doesn't. I don't know how to tell RegEx "If its the first word on the line, and it matches a keyword, highlight it"</p>