Regexp: extract first occurrence of date in string
I would like to extract first date from a string:
txt <- "first date is 05.12.2009. Second date is 06.12.2009." txt
[1] "first date is 05.12.2009. Second date is 06.12.2009." I tried:
sub("^.*?\\s(\\d{1,2}\\.\\d{1,2}\\.\\d{4})", "\\1", txt, extended=T, perl=T)
[1] "05.12.2009. Second date is 06.12.2009."
How to modify this? -J