You can use the following approach with gregexpr and regmatches if you don't know the number of matches in a string.
vec <- c("the text I need to extract
",
"abc another text def and another text ghi")
regmatches(vec, gregexpr("(?<=).*?(?=)", vec, perl = TRUE))
# [[1]]
# [1] "the text I need to extract"
#
# [[2]]
# [1] "another text" "and another text"