-1

I have an object created from an rtf document using the code:sample_doc <- read_rtf("sample.doc") (I had to use read_rtf because the document is actually an rtf).

I know somewhere in the document there are two phrases (an element in the character vector) apple and orange and that there must be an element in between them. I just want to extract that in-between element. What should I do?

Thanks!

Ronak Shah
  • 377,200
  • 20
  • 156
  • 213
sli1991
  • 11
  • 2

1 Answers1

-1

You can use positive lookbehind and lookahead to target the pattern in between, this regex should give u what u need:

(?<=orange)(.*)(?=apple)
marcos
  • 4,473
  • 1
  • 10
  • 24