I'm trying to extract values in a form from a word document so that I can tabulate them. I used the antiword package to convert the .doc into a character string, now I'd like to pull out values based on markers within the document.
For example
example<- 'CONTACT INFORMATION\r\n\r\nName: John Smith\r\n\r\nphone: XXX-XXX-XXXX\r\n\r\n'
Name<- grep('\nName:', example, value = TRUE)
Name
This code returns the whole string when I'd like it to just return 'John Smith'.
Is there a way to add an end marker to the grep()
? I've also tried str_extract()
but I'm having trouble formatting my pattern to regex