title: Regular Expression: How to capture text left of "="
body: <p>I'm trying to capture anything on the left side of an equals sign (without the equals sign) from this.</p>
  
  <blockquote>
    <p><code>MSG_TYPE=X12S4F3S3\r\nASID=123456789012\r\n</code></p>
  </blockquote>
  
  <p>I have used <code>(\w*)=</code> but this seems to pick up the equals and the prevailing <code>n</code> of the <code>/n</code></p>
  
  <p>This is for <code>.net</code>.</p>
  
  <p>Sorry, forgot to mention the text is contained within an RTF Document, so basic substring functions are not possible as I'm trying to create CharacterProperties from DocumentRanges.</p>
  
  <pre><code>Regex regEx = new Regex (@"(\w*)=");
  DocumentRange [] docRanges = m_rtfTranslation.Document.FindAll (regEx);
  
  for (int nIndex = 0; nIndex &lt; docRanges.Length; nIndex++)
  {
      CharacterProperties cp = m_rtfTranslation.Document.BeginUpdateCharacters (docRanges [nIndex]);
      cp.ForeColor = Color.SlateBlue;
      m_rtfTranslation.Document.EndUpdateCharacters (cp);
  }
  </code></pre>