title: Regex optimization: negative character class "[^#]" nullifies multiline flag "m"
body: <p>I'm trying to parse a text line by line, catching everything EXCEPT what's after a specific marker, <code>#</code> for example. No escaping to take into account, pretty basic.</p>
  
  <p>For instance, if the input text is:</p>
  
  <pre><code>Multiline input text
  Mid-sentence# cut, this won't be matched
  Hey there
  </code></pre>
  
  <p>If want to retrieve</p>
  
  <pre><code>['Multiline input text',
   'Mid-sentence',
   'Hey There']
  </code></pre>
  
  <p>This is working fine with <code>/(.*?)(?:#.*$|$)/mg</code> (even though there are a few empty matches). However, if I try to improve the regex (by avoiding backtracking and getting rid of empty matches) with <code>/([^#]++)(?:#.*$|$)/mg</code>, it returns</p>
  
  <pre><code>[
  "Multiline input text
  Mid-sentence",
  "
  Hey There"
  ]
  </code></pre>
  
  <p>As if <code>[^#]</code> was including linebreaks, even with the multiline flag on. As far as I can tell I can fix that by adding <code>[^#\n\r]</code> into the class character, but this makes the multiline option kind of useless and I'm afraid it could break on some weird linebreaks in some environments/encoding.</p>
  
  <p>Would any of you know the reason for this behavior, and if there's another workaround? Thanks!</p>
  
  <p><strong>Edit</strong>
  Originally, it happens in PCRE. But even in Javascript with <code>/([^#]+)(?:#.*$|$)/mg</code>, same unwanted multiline behavior. I know I could probably use the language to parse the text line by line, but I'd like to do it with regex only.</p>