title: Syntax highlight design pattern
body: <p>I'm looking for some good overviews of best practices and common patterns for enabling syntax highlighting in a textbox.  It seems like a very common exercise almost all languages have a UI control that enables syntax highlighting in different languages.  I'm just curious to see if there is a common pattern of implementation.</p>
  
  <p>Is everyone using regular expressions?  Is there a repository for regular expressions that are commonly used in syntax highlighting scenarios?</p>
  
  <p>Are there alternative/better approaches to syntax highlighting?</p>
  
  <p><strong>Update</strong></p>
  
  <p>Links to relevant resources about performing syntax highlighting in a given language or concepts related to syntax highlighting would be great.  Lexing (lexical analysis) was brought up in an answer but without a link to learn more.  Anything to help better understand this commonly solved problem would be great.</p>
  
  <p><a href="http://en.wikipedia.org/wiki/Lexical_analysis" rel="nofollow noreferrer">Lexical Analysis on Wikipedia</a></p>