title: Perl regexp how to negate a part
body: <p>I have to disjuncts </p>
  
  <pre><code>D= d1| d2|...|dn
  </code></pre>
  
  <p>and </p>
  
  <pre><code>F=f1|f2|...|fn
  </code></pre>
  
  <p>at the moment I check those two regexp with an if-statement looking like this:</p>
  
  <pre><code>if (($text_to_search =~ $D) &amp;&amp; ($text_to_search !~ $F))
  </code></pre>
  
  <p>How can I negate F? Is it possible to use a negative lookaround for the whole disjunct Or every single disjunct of F? </p>
  
  <p>I should look like this:</p>
  
  <pre><code>regexp = (d1)| (d2) | (d3)  ... (dn) | NOT (f1) | NOT (f2) | ... | Not (fn)
  </code></pre>
  
  <p>The brackets are necessary for negating the pattern and not only the first single char, arn't they?</p>
  
  <p>Edit:
  for example D is: <code>a|b|c|d</code> and F is: <code>1|2|3</code></p>
  
  <p>now the the behaviour should be like this:</p>
  
  <pre><code>input: "abc" --&gt; accepted
  input: "a" --&gt; accepted
  input: "abc1" --&gt; Not accepted
  input: "2" --&gt; NOT accepted
  input: "a2bc1" --&gt; Not accepted
  (input: "xyz999" --&gt; does not match - shouldn't be accepted)
  </code></pre>
  
  <p>The F-disjunct should be like "when seeing this in the input sequence do not match"</p>