I would like to remove a single occurrence of a word from a string:
str = "I would like to remove THIS word but not THIS word"
I only want to remove the first 'THIS', giving the result:
str = "I would like to remove word but not THIS word"
I was thinking of something along the lines of index:
word = 'THIS'
word.length # => 4
str.index(word) # => 23
Is there any way to say, remove 4 characters after the 23rd character?
I see there are a lot of ways to remove the leading and trailing characters, but not sure about inner characters. Gsub would remove all instances of the word, which is not what I'm looking for.