title: combining negation to and with other expressions
body: <p>I am trying to combine several regex expressions with "and". I have each individual regex working, but am not sure how I can combine them together in such a way that the end result "ands" each expression together.</p>
  
  <p>I am trying to</p>
  
  <pre><code>1) check for a sequence of certain words.
  2) check to see if certain words appear at most once
  3) check for absence of certain words (using negation)
  </code></pre>
  
  <p>As an example, want to accomplish all three:</p>
  
  <pre><code>1) check if "foo" precedes "bar" in the string
  2) check to see if "foo" and "bar" each appear only once
  3) check to see if "hello" and "world" do NOT appear
  </code></pre>
  
  <p>This string should match: <code>"foo hi bar"</code>, but <code>"foo hello bar"</code> should not, nor should <code>"foo foo bar"</code>.</p>
  
  <p>For (1) and (2) I am able to use:</p>
  
  <p><code>^(?!(.*\bfoo\b.*\bfoo\b)|(.*\bbar\b.*\bbar\b)).*\bfoo\b.*\bbar\b.*$</code></p>
  
  <p>successfully.</p>
  
  <p>For (3) I am able to use lookahead:</p>
  
  <p><code>^((?!\bhello|\bworld).)*$</code></p>
  
  <p>successfully.</p>
  
  <p>However, I do not know how to combine (1) and (2) and (3) together. </p>
  
  <p>I have tried using <code>(?=pattern)(?=pattern)</code> as a way of and-ing, but without success:</p>
  
  <pre><code>^(?=(?!(.*\bfoo\b.*\bfoo\b)|(.*\bbar\b.*\bbar\b)).*\bfoo\b.*\bbar\b.*)(?=((?!\bhello|\bworld).))*$
  </code></pre>