title: how to negate any regular expression in Java
body: <p>I have a regular expression which I want to negate, e.g.</p>
  
  <pre><code>/(.{0,4})
  </code></pre>
  
  <p>which String.matches returns the following </p>
  
  <pre><code>"/1234" true
  "/12" true
  "/" true
  "" false
  "1234" false
  "/12345" false
  </code></pre>
  
  <p>Is there a way to negate (using regx only) to the above so that the results are:</p>
  
  <pre><code>"/1234" false
  "/12" false
  "/" false
  "" true
  "1234" true
  "/12345" true
  </code></pre>
  
  <p>I'm looking for a general solution that would work for any regx without re-writing the whole regex.</p>
  
  <p>I have looked at the following 
  <a href="https://stackoverflow.com/questions/2637675/how-to-negate-the-whole-regex">How to negate the whole regex?</a> using (?! pattern), but that doesn't seem to work for me.</p>
  
  <p>The following regx</p>
  
  <pre><code>(?!/(.{0,4}))
  </code></pre>
  
  <p>returns the following:</p>
  
  <pre><code>"/1234" false
  "/12" false
  "/" false
  "" true
  "1234" false
  "/12345" false
  </code></pre>
  
  <p>which is not what I want.
  Any help would be appreciated.</p>