title: Perl regex to match unbalanced token before line ends
body: <p>I am trying to match lines with unbalanced tokens before end of line (no nesting).</p>
  
  <p>It is easy to match lines if token is a single character with <code>/{[^}]*$/</code>. It matches lines with open <code>{</code> like:</p>
  
  <pre><code>Some text {some text
  </code></pre>
  
  <p>And do not match terminated pairs on the same line like:</p>
  
  <pre><code>Some text {some} text
  </code></pre>
  
  <p>That's how it should work. But I am struggling to match unbalanced multicharacter tokens like <code>&lt;a&gt; &lt;/a&gt;</code> or any <code>&lt;blah&gt; &lt;/blah&gt;</code>.</p>
  
  <p>Basically would need something similar to single char matching regex above replacing <code>[^}]*</code> to negation of multichar string before end of line anchor.
  Experiments with negative lookahead or lookbehind like <code>|&lt;a&gt;.*(?!&lt;/a&gt;).*$|</code> were not fruitful (naturally, as it seems if <code>(?!..)</code> is not strictly anchored then it will always find a place where this assertion is true, i.e. closing tag is not there hence it matches any line which has an open tag..</p>
  
  <p>Intuitively I feel like missing something simple (or not) ?</p>