title: R: Regex to match more than one pipe occurrence
body: <p>I have a dataset in which I paste values in a dplyr chain and collapse with the pipe character (e.g. " | ").  If any of the values in the dataset are blank, I just get recurring pipe characters in the pasted list. </p>
  
  <p>Some of the values look like this, for example:</p>
  
  <pre><code>badstring = "| | | | | | GHOULSBY,SCROGGINS | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | CAT,JOHNSON | | | | | | | | | | | | BURGLAR,PALA | | | | | | | | |"
  </code></pre>
  
  <p>I want to match all the pipes that occur more than once and delete them, so that just the names appear like so:</p>
  
  <pre><code>correctstring = "| GHOULSBY,SCROGGINS | CAT,JOHNSON | |BURGLAR,PALA |"
  </code></pre>
  
  <p>I tried the following, but to no avail:</p>
  
  <pre><code>mutate(names = gsub('[\\|]{2,}', '', name_list)) 
  </code></pre>