title: How do you replace words that repeat themselves one after another in R?
body: <p>I want to substitute all the strings that have words that repeat themselves one after another with words that have a single occurrence.</p>
  
  <p>My strings go something like that:</p>
  
  <pre><code>text_strings &lt;- c("We have to extract these numbers 12, 47, 48", "The integers numbers are also interestings: 189 2036 314",
                "','is a separator, so please extract these numbers 125,789,1450 and also these 564,90456", "We like to to offer you 7890$ per month in order to complete this task... we are joking", "You are going to learn 3 things, the first one is not to extract, and 2 and 3 are simply digits.", "Have fun with our mighty test, you are going to support science, progress, mankind wellness and you are going to waste 30 or 60 minutes of your life.", "you can also extract exotic stuff like a456 gb67 and 45678911ghth", "Writing 1 example is not funny, please consider that 66% is validation+testing", "You you are a genius, I think that you like arrays A LOT, [3,45,67,900,1974]", "Who loves arrays more than me?", "{366,78,90,5}Yes, there are only 4 numbers inside", "Integers are fine but sometimes you like 99 cents after the 99 dollars", "100€ are better than 99€", "I like to give you 1000 numbers now: 12 3 56 21 67, and more, [45,67,7]", "Ok ok 1 2 3 4 5 and the last one is 6", "33 trentini entrarono a Trento, tutti e 33 di tratto in tratto trotterellando")
  </code></pre>
  
  <p>I tried:</p>
  
  <pre><code>gsub("\b(?=\\w*(\\w)\1)\\w+", "\\w", text_strings, perl = TRUE)
  </code></pre>
  
  <p>But nothing happened (the output remained the same).</p>
  
  <p>How can I remove the repeating words such as in </p>
  
  <pre><code>text_strings[9]
  #[1] "You you are a genius, I think that you like arrays A LOT, [3,45,67,900,1974]"
  </code></pre>
  
  <p>Thank you!</p>