title: Regular expression negation in R
body: <p>I have a problem trying to find a way to implement negation in R regular expressions.</p>
  
  <pre><code>my_strings &lt;- c("a non-rheumatic fever", "a nonrheumatic fever", "a rheumatic fever", "a not rheumatic fever")
  my_strings
  ## [1] "a non-rheumatic fever" "a nonrheumatic fever" "a rheumatic fever" "a not rheumatic fever"
  </code></pre>
  
  <p>In the above string, I'm trying to find a regular expression that will output just the following:</p>
  
  <pre><code>## [1] "a rheumatic fever"
  </code></pre>
  
  <p>I've tried the following but I can't figure out how to negate the presence of <code>"no(n|t)(\\s+|-)?"</code> immediately preceding <code>"rheumatic"</code>:</p>
  
  <pre><code>t_inc &lt;- "\\b([^n][^o][^nt](\\s+|-)?(rheumatic))\\b"
  grep(t_inc, my_strings, ignore.case = T, perl = T, value = T)
  ## character(0)
  
  t_inc &lt;- "\\b([^(no(n|t))](\\s+|-)?(rheumatic))\\b"
  grep(t_inc, my_strings, ignore.case = T, perl = T, value = T)
  ## character(0)
  </code></pre>
  
  <p>Please could someone give me some pointers?</p>