For example I have the following string:
sample = "I am a good guy; he is cool; I am a cool dude; let's do it!"
I am a good guy
I am a cool dude
Here is a stringr library solution:
str_match_all(sample, "I am.*?;") #[] # [,1] #[1,] "I am a good guy;" #[2,] "I am a cool dude;"
stringer has several very powerful functions for dealing with splitting and extracting information from strings.