I am doing a regex to only extract the first sentence of each paragraph. At the moment, I have a input vector like this:
text_insert <- c("hello, i am working through an r workbook. I am doing a regex expression.", "hi, how are you? I am great working through r")
My R code at the moment is:
gsub(pattern = "\\..*", replacement = ".", x = text_insert)
However this does not recognize ?
or !
as the end of a sentence.
Any help of how to recognize !
and ?
as the end of sentence as well?