title: How to replace everything but a specified string using regex
body: <p>I've been looking through and out of stackoverflow for this, but I haven't had any luck.</p>
  
  <p>The string I want to work with is "xbananay", where 'x' and 'y' can be any random combination of letters or numbers with any length. So my string could simply be "qrstbananag", but it could also be "abcbanana12345" for example. </p>
  
  <p>I want to use, <strong>and only use</strong>, javascript's replace function to replace everything BUT "banana". I already have some regex that can find banana, but the replace function, as intended, will replace what I am looking for, when I want to find everything else. Example:</p>
  
  <pre><code>var fullString = "qrstbananag"
  var strippedBanana = fullString.replace(/(?:banana)/g, ''); //returns qrstg
  </code></pre>
  
  <p>I also have a regex expression that ALMOST gets me what I am looking for, but includes all characters in the string "banana". Another example:</p>
  
  <pre><code>var fullString2 = "abcbanana12345"
  var strippedBanana = fullString2.replace(/[^(?:banana)]/g, ''); //returns abbanana
  </code></pre>
  
  <p>How might I accomplish this using only the replace function? Thanks in advance.</p>