my_names <- c('a\nb\nc')

library(stringr)

str_extract(my_names, 'a(.|\r\n?|\n)*b.*')
