title: Replace the whole word that starts with a pattern using gsub in R
body: <p>I'm having issues with a problem that should be so simple to resolve.
  I'd like to replace the whole words in a string which start with a pattern.</p>
  
  <pre><code>&gt; test &lt;- "i really wasn aware and i wasnt aware at all. but i wasn't aware. just wasn't."
  
      ## this is what i want
      &gt; output
  [1] "i really wasn't aware and i wasn't aware at all. but i wasn't aware. just wasn't."
  </code></pre>
  
  <p>the best one I've come with so far is this</p>
  
  <pre><code># this is what get, but it's not correct
  &gt; gsub("\\&lt;wasn*.\\&gt;", "wasn't", test)
  [1] "i really wasn't aware and i wasn't aware at all. but i wasn't't aware. Just wasn't't."
  </code></pre>
  
  <p>I'm really running out of ideas. I would also be happy with </p>
  
  <pre><code> # second desired output without the . at the end
      &gt; output
      [1] "i really wasn't aware and i wasn't aware at all. but i wasn't aware. just wasn't"
  </code></pre>
  
  <hr>
  
  <p>Edit: it seems my question was a bit too specific. so, i'm adding other test cases. Basically, i wouldn't know what character(s) would follow "wasn" and i would like to convert all to wasn't</p>
  
  <pre><code>&gt; test &lt;- "i really wasn aware and i wasnt aware at all. but i wasn't aware. just wasn't. this wasn45'e meant to be. it wasn@'re simple"
  &gt; test
  [1] "i really wasn aware and i wasnt aware at all. but i wasn't aware. just wasn't. this wasn45'e meant to be. it wasn@'re simple"
  
  #desired output
  &gt; output
   [1] "i really wasn't aware and i wasn't aware at all. but i wasn't aware. just wasn't. this wasn't meant to be. it wasn't simple"
  </code></pre>