I am trying to remove all digits in a string except the first set of digits. So in other words, all repeating sets of digits, there could be 1 sets or 10+ sets in the string but I only want to keep the first set along with the rest of the string.
For example, the following string:
x <- 'foo123bar123baz123456abc1111def123456789'
The result would be:
foo123barbazabcdef
I am have tried using gsub
and replacing \d+
with an empty string but this replaces all digits in the string, I have also tried using groups to capture some of the results but had no luck.