Strings In Depth9 / 12
Up next

sub and gsub

s <- "a-b-c-d"
# sub replaces only the first match
print(sub("-", "_", s))
# gsub replaces every match
print(gsub("-", "_", s))
What you're solving

replace matches