title: Rule cannot be matched in Flex (LEX) when using ^
body: <p>I'm trying to run some simple regex in Flex but I cannot get the operator &quot;^&quot; to work as a negation.
  This is my code:`</p>
  <pre><code>%%
  
  
  [^abc]      printf(&quot;rule triggered\n&quot;);
  .       
  \n
  </code></pre>
  <p>It should just match any character that is not &quot;a&quot;, &quot;b&quot; or &quot;c&quot;, but instead I get a:
  &quot;warning, rule cannot be matched&quot;.</p>
  <p>The other uses for &quot;^&quot; seem to work fine, ^a matches any string that starts with &quot;a&quot; and [a^b] matches any string that contains &quot;a&quot; or &quot;b&quot;. Also, strangely enough the rule [^a] works as expected if preceded by something else, such as:</p>
  <pre><code>%%
  
  b+[^a]      printf(&quot;rule triggered\n&quot;);
  .
  \n
  </code></pre>
  <p>This matches a string that begins with any number of &quot;b&quot;s that are not followed by an &quot;a&quot; and seems to work correctly. But it won't work if I allow zero occurences of &quot;b&quot; as in:</p>
  <pre><code>%%
   
  b*[^a]      printf(&quot;rule triggered\n&quot;);
  .       
  \n
  </code></pre>
  <p>This gives the same &quot;warning, rule cannot be matched&quot; and sure enough, doesn't work. Kinda stumped here.</p>
  <p>ps. I'm using Flex  in cycgwin if that matters (it should be compatible with all Lex syntax).</p>
  <p>`</p>