title: Matching end of line or another character
body: <p>I am trying to write a regex which can match "key = value" up until end of line or a symbol indicating that a comment beginns. </p>
  
  <p>For example, let '#' indicate a comment and assume I have a file containing the following:</p>
  
  <pre><code>k1 = v1 
  k2 = v2 # this is a comment
  k3 = v3
  </code></pre>
  
  <p>Then I want my expression to match upon "k1 = v1", "k2 = v2" and "k3 = v3". </p>
  
  <p>I have been able to match text with no comments using:</p>
  
  <pre><code>^(?'key'.+)\=(?'value'.+)
  </code></pre>
  
  <p>The problem is that I cannot figure out how to match up until '#' or '\n'</p>