title: Regex to negate the whole word?
body: <pre><code>  String test1 = "This is my test string";
  </code></pre>
  
  <p>I want to match a string which does not contain "test"</p>
  
  <p>I can do it with</p>
  
  <pre><code> Pattern p = Pattern.compile(".*?^(test).*?")
  </code></pre>
  
  <p>and it works but at most of sites like <a href="https://stackoverflow.com/questions/977251/regular-expressions-and-negating-a-whole-character-group">Regular Expressions and negating a whole character group</a>
      <code>^(?!.*test).*$</code>  is suggested which did not work for me. </p>
  
  <p>As per my understanding <code>^(test)</code> is sufficient so why  <code>^(?!.*test).*$</code> is required?</p>