Skip to main content

sub vs gsub

sub stands for substitute

sub will replace the first occurence of a text
eg:
("yes yes").sub("yes", "no")    # "no yes"

("yes yes").gsub("yes", "no")  # "no no"

Comments