0

I'd like to replace one or more than one full-stop in my strings with a blank.

I've tried the following, but either none of the full-stops gets replaced with a blank, or the entire string gets replaced with a blank.

# Toy Data
book = c("eggs.", "flour...", "..butter", "bakingpowder", "coco..dark")

# Attempt at replacing full stops with blanks
gsub(".+", "", book)

sub("(.+)", "", book)

gsub(".\\+", "", book)

sub("(.\\+)", "", book)

# Expected result
book = c("eggs", "flour", "butter", "bakingpowder", "cocodark")

Thanks for any help!

Robbie
  • 275
  • 4
  • 20

0 Answers0