 <p>You could use the <code>stringr</code> package with the following regular expression (anchored at the front of the string using <code>^</code>):</p> <pre><code>library(stringr) sentences &lt;- c("I went to the store last night", "I went to the park yesterday", "I went to starbucks this morning") str_replace(sentences, "^I went to( the)?", "REPLACED") # [1] "REPLACED store last night" "REPLACED park yesterday" # [3] "REPLACED starbucks this morning" </code></pre> <p>If there are multiple instances to replace within the same string, you may want to omit the <code>^</code> and use <code>str_replace_all()</code></p>