I'm trying to split a string by multiple criteria and store the splitting criteria for each split.
I have been trying to use the stringr::str_split
package but cannot pass more than one splitting criteria to the function.
For example if I have the following string:
data = "Julie (title) : This is the text Julie has: said. Extra sentence one. Extra sentence 2 and so on. Rt Hon Ellen: This is the text Ellen has said in response to Julie. TITLE OF SECTION Julie: More words from Julie."
and splitting criteria:
names = c("Julie:", "Ellen:")
I would like an output like this:
data.frame(Names = c("Julie:", "Ellen:","Julie:"),
text = c(" This is the text Julie has: said. Extra sentence one. Extra sentence 2 and so on. ", "This is the text Ellen has said in response to Julie.","More words from Julie."))