title: Regular expression to match string ending with letter but NOT ending with a phrase in R
body: <p>I need to use <code>grep</code> to find all strings ending with <code>G</code> but NOT ending with <code>STIG</code> or <code>VÄG</code> in the following character vector:</p>
  
  <pre><code>test=c("EWASPG","AVOPW","SDAGSTIG","ASDVVÄG","ASDVWE","QSCIUVG","QWSFNJG")
  </code></pre>
  
  <p>I tried this but it returns false for any string with the letters <code>S</code>, <code>T</code> , <code>I</code>, <code>V</code>, <code>Ä</code> preceding the <code>G</code> instead of returning false when the <code>G</code> is preceded by the exact phrase.</p>
  
  <pre><code>grep("[^((STI)|(VÄ))]G$", test, value=T)
  
  # [1] "EWASPG"  "QWSFNJG"
  </code></pre>
  
  <p>Thanks!</p>
  
  <p>I am aware of <a href="https://stackoverflow.com/questions/8438173/r-regex-match-strings-not-beginning-with-a-pattern">this post</a>.</p>