title: gsub replace pattern with backspace
body: <p>I have a data set with a column that contains a label with the year (<code>OldLabel</code>), and I want to make another column that contains only the label, not the year (<code>NewLabel</code>). I wrote the following code, but it leaves a space at the end of the new labels.</p>
  
  <pre><code>data["NewLabel"] &lt;- gsub("20..", "", data$OldLabel)
  #removes any part of the OldLabel column that starts with 20 and ends with 2 digits, e.g: 2011 or 2008
  </code></pre>
  
  <p>Is there a way to have gsub replace the sequence with a backspace, so it gets rid of any spaces around the year it replaces? I tried using <code>"\\b"</code> as my replacement text, but that just replaced it with <code>b</code>, not a backspace.</p>
  
  <p>EDIT: Per request, an example of <code>OldLabel</code> would be <code>"Valley Summer 2014"</code>, which should become <code>"Valley Summer"</code>, but ends up being <code>"Valley Summer "</code> with my current code. However, some might also be of the form <code>2012 Valley Summer</code>, so I don't think simply including a space in the pattern would be robust enough.</p>