I have the following character string
test <- "Mr Flowerpower discusses the challenges for the flower economy\r\nSpeech given by the Head of the Bank
of Flowerland, Mr Yellow Flowerpower, at the Flowerland meeting\r\non 27 July 2089.\r\n
* * *\r\nI. Introduction\r\nIt is a great day to talk to all these flower investors. "
which is an input from a pdf text. My aim would be to extract everything up to the stars * * *.
- Use gsub - match everything after the pattern of the stars an replace it by blank space
gsub("\\s\\s\\s\\s\\*\\s\\s\\s\\s\\*\\s\\s\\s\\s\\*.*","",test)
[1] "Mr Flowerpower discusses the challenges for the flower economy\r\nSpeech given by the Head of the Bank
of Flowerland, Mr Yellow Flowerpower, at the Flowerland meeting\r\non 27 July 2089.\r"
- Use str_extract: I would like to extract everything (.*) before the pattern:
str_extract(test, ".*\\s\\s\\s\\s\\*\\s\\s\\s\\s\\*\\s\\s\\s\\s\\*")
[1] "\n * * *"
However, the second option does not work. I think it does not work because . does not match "/n". However, what would be the right approach here to extract everything before the * * * pattern? Thanks for your help!