qdapRegex icon indicating copy to clipboard operation
qdapRegex copied to clipboard

Is there a way to extract only the second or third (for example) occurrence of a pattern in the string?

Open bes827 opened this issue 4 years ago • 4 comments

This is an excellent package, can get a lot of work done with minimal coding. And is educational as well (as the author described); it teaches the basics of regex in r.

This is a small example to illustrate my question:

d = "started on 09/29/1980, continued till 02/11/2020, last noted 2/14/2020"   
rm_date(d, extract=TRUE)

when I run this code, it extracts the 3 dates in the string.

[1] "09/29/1980" "02/11/2020" "2/14/2020"

is there a way to extract only the second or the third?

thank you

bes827 avatar Jul 28 '20 01:07 bes827