[Solved] how to remove all text before a pattern? [duplicate]


To solve this problem you can use a positive lookahead '.*(?=START)', as follows:

# load environment
library(stringr)
# create text vector
text = c('hello guys this is it START hi',
         'one two START this is good',
         'a longer example. I cannot believe it! START hello')
# remove pattern
text = str_remove(text, '.*(?=START)')
# print output
print(text)

Here is the output:

[1] "START hi"           "START this is good" "START hello"

4

solved how to remove all text before a pattern? [duplicate]